2012-03-15 130 views
1

我確定我的問題已在某個地方解決,但我已經研究了一段時間,似乎無法找到我正在尋找的答案。關於JqGrid的問題和問題

  • 當使用inlineNav功能時,是否有「刪除」選項?我還沒有發現任何,所以爲了使用它,我必須同時使用navGridinlineNav功能創建的網格,就像這樣:
$("#attributeEditList").jqGrid({ 
      datatype: "local", 
      height: 150, 
      colNames: ['rowid', 'Vendor', 'Category', 'Key', 'Value', 'Flags', 'Status'], 
      colModel: [ 
         {name: 'rowid', index: 'rowid', hidden: true, key: true}, 
         {name: 'vendorCode', index: 'vendorCode', hidden: true}, 
         {name: 'category', index: 'category', width: 120, editable: true, editrules:{required: true} }, 
         {name: 'key', index: 'key', width: 120, editable: true, editrules:{required: true} }, 
         {name: 'value', index: 'value', width: 200, editable: true, editrules:{required: true} }, 
         {name: 'flags', index: 'flags', width: 80, editable: true, editrules:{required: true, integer: true} }, 
         {name: 'status', index: 'status', hidden: true } 
         ], 
      sortname: "category", 
      viewrecords: true, 
      caption: "Attributes", 
      rowNum: 20000, 
      pager: '#attributeEditPager', 
      editurl: "vendor/ajax/dummy.do", 
      data: vendor.attributes, 
      jsonReader : { repeatitems: false } 
      }); 
      $("#attributeEditList").jqGrid("navGrid", '#attributeEditPager', { 
       edit: false, 
       add: false, 
       del: true, 
       search: false, 
       refresh: false, 
       delfunc: deleteAttribute 
      } 
     ); 
      $("#attributeEditList").jqGrid("inlineNav", '#attributeEditPager'); 
  • 有沒有什麼辦法,使嚴格在客戶端對網格進行編輯?我希望我的用戶能夠進行一些編輯(添加/編輯/刪除),然後發佈網格中的所有更改,以及網格外部的其他一些表單更改,以原子方式返回到服務器。據我所知,editurl參數是必需的,並且實際上必須是有效的url,才能進行編輯。
  • 最後,我認爲這是我遇到的最大問題,就是在使用inlineNav功能時。首先,我點擊「添加(+)」按鈕添加一行,添加數據,然後點擊「保存」按鈕。然後,如果再次單擊「添加」按鈕,將添加新行,但「添加」和「編輯」按鈕保持活動狀態,而「保存」和「取消」按鈕仍處於禁用狀態。

如果您對這些問題有任何建議,請告訴我。

回答

1

查看the demo來自the old answer我在這裏演示瞭如何在jqGrid中實現本地表單編輯。你第一個問題是關於navGrid增加的「刪除」。所以你可以使用這個技巧來設置processing: true,我建議在本地使用「刪除」按鈕。您還應該使用editurl: 'clientArray'。我在一年前發佈了我的建議(見here),但本地表單編輯仍然不是jqGrid的一部分。

你說得對,inlineNav有許多情況下會出現故障,並且如果用戶按其他小命令點擊按鈕,則會出現錯誤的激活或錯誤停用按鈕。您必須使用$("#attributeEditList_ilsave").removeClass('ui-state-disabled');$("#attributeEditList_ilsave").addClass('ui-state-disabled');手動激活/停用按鈕。按鈕的ID將由gridid和後綴「_iladd」,「_iledit」,「_ilsave」,「_ilcancel」構造而成。我建議你在onSelectRowbeforeSelectRow中包含這樣的代碼,直到bug在jqGrid的主代碼中不會被修復。

+0

關於最後一個問題,是否在連續編輯時觸發事件?否則,我將如何知道該行是否處於編輯模式? – pconrey 2012-03-15 23:01:16

+0

另外,爲了記錄,下面是第二次單擊「添加」按鈕時發生的錯誤堆棧的第一部分(來自Chrome中的開發人員工具):
未捕獲的TypeError:無法讀取屬性「name」未定義
$ .jgrid.extend.editRow.each.svr.id
e.extend.each
e.fn.e.each
$ .jgrid.extend.editRow
e.extend.each 的
e.fn.e.each
$ .jgrid.extend.editRow $ .fn.jqGrid ... – pconrey 2012-03-15 23:01:49

+0

@pconrey:您可以使用[$。 jgrid.inlineEdit](https://github.com/tonytomov/jqGrid/blob/v4.3.1/js/grid.inlinedit。js#L35-46)設置任何類似於'oneditfunc'的回調函數,這將在內聯編輯開始時調用。您還可以使用[inlineNav](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#inlinenav)選項中的editParams.oneditfunc'和'addParams.addRowParams.oneditfunc'。 。您可以嘗試從[github](https://github.com/tonytomov/jqGrid/)使用當前版本的jqGrid。它包含一些重要的錯誤修復。 – Oleg 2012-03-15 23:10:56