2012-07-30 78 views
0

我有一個過濾本地數據的問題。如果我刪除loadonce參數並從服務器獲取結果,一切正常。當我想要過濾本地數據時出現問題。 這是我的網格實現:jqGrid filterToolbar和本地搜索不起作用

orderPosGrid.jqGrid({ 
     colNames: ['', '', '', '', '', '', '', 'ID', 'Nazwa/Rodzaj', 'Ilość', 'Jedn.', 'Przyczyna zwrotu', 'Napis', '', ''], 
     colModel: [ 
      {name: 'myac', index:'myac', width:0, hidden:true}, 
      {name: 'commited', index: 'commited', width: 0, editable: false, hidden: true}, 
      {name: 'hasIlosc', index: 'hasIlosc', width: 0, editable: false, hidden: true}, 
      {name: 'hasOpis', index: 'hasOpis', width: 0, editable: false, hidden: true}, 
      {name: 'opisCount', index: 'opisCount', width: 0, editable: false, hidden: true}, 
      {name: 'id', index: 'id', width: 0, sorttype: 'int', editable: false, hidden: true}, 
      {name: 'qType', index: 'qType', width: 0, sorttype: 'int', editable: false, hidden: true}, 
      {name: 'id_prod', index: 'id', width: 30, sorttype: 'int', editable: false}, 
      {name: 'nazwa', index: 'name', width: 250, editable: false}, 
      {name: 'ilosc', index: 'quantity', width: 35, align: 'right', sortable: false, search:false, edittype:'text', editable: true, editrules:{custom:true, custom_func:iloscValidate, minValue:1}}, 
      {name: 'jedn', index: 'jedn', width: 35, sortable: false, search:false, align: 'right', editable: false}, 
      {name: 'opisZwrot', index: 'opisZwrot', width: 170, sortable: false, editable: true, search:false, edittype:'select', formatter: 'select', editoptions:{value:'{{ przyczZwrot }}'}}, 
      {name: 'opis', index: 'description', width: 170, sortable: false, search:false, editable: true}, 
      {name: 'group', index: 'group', editable: false, hidden: true}, 
      {name: 'info', index: 'info', sortable: false, search:false, width: 22} 
     ], 
     status: 0, 
     url: '/ProdList/'+type_id+'/'+order_id+'/', 
     datatype: 'json', 
     mtype: 'GET', 
     ignoreCase:true, 
     height: 'auto', 
     rowNum: 10000, 
     loadonce:true, 
     gridview: true, 
     viewrecords: true, 
     sortname: '', 
     sortorder: '', 
     pager: '#ProdList_gridPager', 
     caption: 'Lista dostępnych produktów', 
     subGrid: false, 
     editurl: 'clientArray', 
     grouping: true, 
     groupingView: { 
      groupField: ['group'], 
      groupOrder: ['asc'], 
      groupColumnShow: [false], 
      groupText: ['<b>{0} [{1}]</b>'], 
      groupCollapse: false 
     }, 
... 
}); 

我只在兩個字段進行過濾:ID由...和,其他人都被禁止。 從服務器的json數據是這樣的:

{"total":1, "page":"1", "records":"266", "rows":[{"id": "2473_1", "cell":["","1","0","0","","116","1","2473","Adwokat","3","kg.","","","d - Ciasta kremowo-śmietanowe"]},{"id": "2473_2", "cell":["","1","0","0","","116","1","2473","Adwokat","2","kg.","","","d - Ciasta kremowo-śmietanowe"]},{"id": "2473_3", "cell":["","1","1","1","70","116","1","2473","Adwokat","","kg.","","","d - Ciasta kremowo-śmietanowe"]}]} 

我覺得我用典型的數據配置,不需要jsonReader配置。 我錯了嗎? 如果您在我的代碼中發現一些錯誤,請幫助。

+0

你試過用jsonReader配置嗎? – 2012-07-30 12:53:14

+0

是的,我嘗試使用此代碼: jsonReader:{ \t根: 「行」, \t頁: 「頁」, \t總: 「總」, \t記載: 「記錄」, \t repeatitems:真實, \t細胞: 「細胞」, \t ID: 「ID」 \t}, 沒有成功 - 仍數據消失的時候,我把filterToolbar領域的一些信件。 – sztubi 2012-07-30 18:49:25

回答

0

檢查來自Oleg的這個答案。 jqGrid client-side searching

如果你正在尋找的東西,那麼你需要實現它,那麼你的實現代碼在哪裏?檢查上面的鏈接,他在那裏保存搜索條件。

+0

此答案適用於單字段搜索,但我使用了filterToolbar。無論如何感謝迴應。 當然我使用: orderPosGrid.filterToolbar({searchOnEnter:false,stringResult:true}); – sztubi 2012-07-30 18:53:29

+0

任何人都有類似的問題filterToolbar?當我把東西放在垃圾場時,每一行都消失了。感謝您的任何建議。 – sztubi 2012-08-02 12:35:02