【发布时间】:2015-11-09 12:34:27
【问题描述】:
我已经实现了一个启用了工具栏搜索的 jqGrid。 问题是搜索的工作方式类似于“%search_criteria”(仅从头开始匹配) 但我需要它像 '%search_criteria%' (列值中的任何出现)。
例如:网格有一个“类”列,其值为:Math-101 和 Math-102 如果搜索:“101”==> 得到零匹配。 我必须搜索整个单词“Math-101”。
我看到了一个我不会工作的示例,它与我的 Grid 没有什么不同,我不知道它在下面的示例中是如何工作的,而不是在我的示例中! 例如:http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridWithSearchingToolbar.htm
我的网格:
var data = [[1, "Math-101", "OC", "INTEL", "09-02-15", "09-30-15", "A", 120, "General", 200]]
$("#grid").jqGrid({
datatype: "local",
height: 200,
colNames:['#','Class','Loc','Type','Start Dt','End Dt','Section','Dur','Gen/Priv','Fee'],
colModel: [
{name: 'scheduleID', index: 'scheduleID', width: 30},
{name: 'className', index: 'className', width: 60},
{name: 'Location', index: 'Location', width: 60},
{name: 'classType', index: 'classType', width: 60},
{name: 'startDt', index: 'startDt', width: 60, sorttype: "date",
searchoptions:{dataInit:function(el){$(el).datepicker({dateFormat:'yy-mm-dd'});} }},
{name: 'endDt', index: 'endDt', width: 60, sorttype: "date",
searchoptions:{dataInit:function(el){$(el).datepicker({dateFormat:'yy-mm-dd'});} }},
{name: 'section', index: 'section', width: 60},
{name: 'duration', index: 'duration', width: 60},
{name: 'scheduleType', index: 'scheduleType',width: 60},
{name: 'Fee', index: 'Fee', width: 60, formatter:'number', align:'right'}
],
pager: '#pager',
rowNum: 10,
rowList: [10, 20, 30],
rownumbers: true,
sortname: "Class",
sortorder: "desc",
viewrecords: true,
gridview: true,
ignoreCase: true,
autoencode: true,
autowidth: true,
ExpandColClick: true,
caption: "Schedule List"
});
var names = ['scheduleID', 'className', 'Location', 'classType', 'startDt', 'endDt', 'Section', 'duration', 'scheduleType', 'Fee', 'CEU', 'Status', 'IFee', 'TCost', 'FCost', 'MCost', 'OMCost'];
var mydata = [];
for (var i = 0; i < data.length; i++) {
mydata[i] = {};
for (var j = 0; j < data[i].length; j++) {
mydata[i][names[j]] = data[i][j];
}
}
for (var i = 0; i <= mydata.length; i++) {
$("#grid").jqGrid('addRowData', i + 1, mydata[i]);
}
$("#grid").jqGrid('filterToolbar', { stringResult: true, searchOperators: false, searchOnEnter: false, autosearch: true, defaulySearch: "cn" });
感谢您的帮助。
【问题讨论】:
标签: javascript jquery jqgrid