0
我有一个需要在jqgrid本地过滤数据,而无需使用内置的用户界面。我遵循奥列格在jqGrid Filtering Records后的回答。它像一个魅力,我的设置有一些变化。但是,我似乎无法得到格式化记录的字段。 jqgrid数据是远程的。使用远程数据和格式过滤jqgrid
发布从jqGrid Filtering Records代码示例,因为这是相当多我有什么:
$("#search").click(function() {
var searchFiler = $("#filter").val(), grid = $("#list"), f;
if (searchFiler.length === 0) {
grid[0].p.search = false;
$.extend(grid[0].p.postData,{filters:""});
}
f = {groupOp:"OR",rules:[]};
f.rules.push({field:"name",op:"cn",data:searchFiler});
f.rules.push({field:"note",op:"cn",data:searchFiler});
grid[0].p.search = true;
$.extend(grid[0].p.postData,{filters:JSON.stringify(f)});
grid.trigger("reloadGrid",[{page:1,current:true}]);
});
在我的情况下,字段“名称”的格式中的jqGrid:
{name:"name", index:"name", width:250, align:'left',
formatter: function(cellvalue, options, rowObject)
{
return rowObject.Data[0]['userName'];
}
},
...
jsonReader : {
repeatitems:false,
root: 'rows',
userdata: 'rows'
},
loadonce: true,
viewrecords: true,
autowidth: true,
multiselect: false,
height: 500,
rowNum: 999,
subGrid: true,
我们做查询到后端一次,并将数据存储在'行'中以便在子网格中显示。
任何指针,非常感谢。
感谢,
阿莎
非常感谢Oleg。它像一个魅力。我想我从来不需要格式化程序。 jsonmap:“Data.0.userName”工作。现在我不确定为什么我首先使用了自定义格式化程序,因为我实际上只是在这里映射数据。你给了我很多选择,所以下次我可以做出更好的决定。 – Alice
@阿莎:不客气!我很高兴能帮助你。 – Oleg
对于过滤可以使其不区分大小写。我尝试添加'var searchFiler = $(“#filter”).val()。toLowerCase(),f',但这会漏掉'name'字段中有'Asha'之类的情况。 – Alice