2013-02-13 53 views
0

我一直在使用jqGrid v4.0並且工作完美,但是由於我升級到了jqGrid v4.4.1,因此FilterTolBar沒有可用的選擇字段。格式化程序選擇不適用於使用jqGrid-v4.4.1的FilterToolBar

這裏是我的代碼:

<script type="text/javascript"> 
$(function() { 
    var grid = $("#grid_container"); 
    grid.jqGrid({ 
     url:'index.php?getData=xml&', 
     datatype: "xml", 
     colNames:['id', 'user','sid', 'Status'], 
     colModel:[ 
      {name:'id', index:'id', width:150, hidden:true}, 
      {name:'user', index:'user', width:150 , stype:'select', editoptions:{value: "Jhon:Jhon;Adam:Adam"}, searchoptions:{sopt:['cn']}}, 
      {name:'sid', index:'sid', width:65 }, 
      {name:'status', index:'status', width:110 }, 
     ], 
     rowNum:20, 
     rowList:[10,20,100], 
     pager:'#grid_pager', 
     sortname: 'user', 
     sortorder: 'desc', 
     height:'100%' 
    }) 
    .jqGrid('filterToolbar' ,{searchOnEnter : true}); 

}); 

謝謝你的任何建議。

回答

0

當前版本的jqGrid是4.4.4。如果您必須使用舊版本,則不僅可以在editoptions中包含相同的value,也可以在searchoptions中包含相同的value。在使用filterToolbar的情況下,建議添加額外的值,專門用於搜索空值。它將不允許過濾列。所以user列的定義可以像下面

{ name: 'user', stype: 'select', 
    editoptions: { value: "Jhon:Jhon;Adam:Adam" }, 
    searchoptions: { sopt: ['eq'], value: ":Any;Jhon:Jhon;Adam:Adam" } } 

您應該考慮刪除隱藏id列,因爲id屬性行(網格的<tr>元素)將基於如果輸入數據的id屬性分配您的正確填寫數據(見the documentation)。如果您不使用數據編輯,則可以刪除editoptions並僅使用searchoptions。我強烈建議您使用"eq"而不是"cn"進行選擇。使用"cn"將不允許您在一個選擇中使用諸如"a","ab"和​​之類的選項。如果用戶選擇"ab",則將選擇"ab"和​​。如果用戶選擇"a",則將選擇樹選項"a","ab"和​​。所以jqGrid不會像用戶所期望的那樣工作。

我建議您另外在所有用來提高性能的網格中包含gridview: true。在大多數使用情況下,還需要使用autoencode: true

+0

像一個魅力工作。 非常感謝! – 2013-02-13 15:03:17

+0

@YassinGerrard:不客氣! – Oleg 2013-02-13 15:20:26