0

在jqgrid行中進行內聯編輯時,它允許再次單擊另一行,然後它不會取消先前的行並且兩者都將保持編輯模式。 我需要它取消最後一個,如果用戶單擊新行進行編輯,單行應該打開編輯。 (如果用戶點擊下一行進行編輯,則最後一行應該被取消,並且只有新行才能被編輯)。在Inine中編輯jqgrid,無法取消先前的編輯事件並切換到新事件

問題在這裏,它切換到新的行進行編輯,但最後一行的「編輯」和「取消」按鈕保持原樣。因此,同時用戶可以看到兩行的編輯,取消按鈕。

 $("#SamplesGrdList").jqGrid({ 
     url: '@Url.Action("ActionName", "Controller")/', 
     datatype: "json", 
     colNames: ['Category Name','ValueToChange','Edit'], 
     colModel: [ 
      { name: 'CategoryName', index: 'CategoryName', sortable: true, sorttype: 'text', width: 140, classes: 'bStyle' }, 
      { 
       name: 'ValueToChange', index: 'ValueToChange', width: 82, align: "right", editable: true, editrules: { number: true, required: true, custom: true, custom_func: Deductions }, formatter: 'currency', 
       formatoptions: { decimalSeparator: ".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00', prefix: '$ ' }, 
       editoptions: { 
        style: 'width:70px;', dataEvents: [ 
         { 
          type: 'blur', 
          fn: function (e) { 
           CalculateDeductions($(this).val());// SOme DB Operation 

          } 
         } 
        ] 
       } 
      }, 
      { 
       name: 'act', index: 'act', width: 60, align: 'center', sortable: false, formatter: 'actions', 
       formatoptions: { 
        keys: false, 
        delbutton: false, 
        onEdit: function (rowid) { 
        }, 
        onSuccess: function (jqXHR) { 
         $("#SamplesGrdList").trigger('reloadGrid'); 
         return true; 
        }, 
        onError: function (rowid, jqXHR, textStatus) { 

        }, 
        afterSave: function (rowid) { 
        }, 
        afterRestore: function (rowid) { 
         $("#SamplesGrdList").trigger('reloadGrid'); 
        } 
       } 
      } 
     ], 
     rowNum: 10, rowList: [10, 20, 30], 
     sortname: 'CategoryName', 
     shrinkToFit: true, 
     sortable: true, 
     viewrecords: true, 
     sortorder: "desc", 
     footerrow: true, 
     width: '780', 
     height: '100%', 
     jsonReader: 
      { 
       root: 'List', 
       page: 'Page', 
       total: 'TotalPages', 
       records: 'TotalCount', 
       repeatitems: false, 
       id: 'Id' 
      }, 

     editurl: '@Url.Action("ActionName", "ControllerName")' 
    }); 

請指導如何解決這個問題,因此,一次只有一行可用於編輯/保存/取消。

注:jqGrid的版本是Jquery.jqgrid-4.1.2.min.js

感謝

回答

0

我認爲,你有唯一的問題:很舊版本使用的jqGrid 4.1.2。我建議你更新到jqGrid 4.7free jqGrid 4.8

只是嘗試the demo例如。它使用你需要的formatter: "actions"。你可以驗證它是否像你需要的那樣工作。