jqgrid-搜索工具栏
第3.7节中的工具栏搜索演示为每个列绘制搜索工具栏。是否可以只使用一个搜索工具栏来过滤所有列和所有页面上的数据 有关更多信息: JSONjqgrid-搜索工具栏,jqgrid,Jqgrid,第3.7节中的工具栏搜索演示为每个列绘制搜索工具栏。是否可以只使用一个搜索工具栏来过滤所有列和所有页面上的数据 有关更多信息: JSON { "mypage":{ "outerwrapper":{ "page":"1", "total":"2", "records":"2", "innerwrapper":{ "rows":[ {
{
"mypage":{
"outerwrapper":{
"page":"1",
"total":"2",
"records":"2",
"innerwrapper":{
"rows":[
{
"id":"1",
"cells": [
{
"fieldType": "image",
"label": "image",
"value": "<img src=icon.gif>"
},
{
"fieldType": "number",
"label": "number",
"value": 100
},
{
"fieldType": "string",
"label": "string",
"value": "James Kisnar"
},
{
"fieldType": "alphanumeric",
"label": "alphanumeric",
"value": "77 Wall Street"
},
{
"fieldType": "date",
"label": "date",
"value": "12/20/2011"
},
{
"fieldType": "decimal",
"label": "decimal",
"value": "23.55"
}
]
},
{
"id":"2",
"cells": [
{
"fieldType": "image",
"label": "image",
"value": "<img src=icon.gif>"
},
{
"fieldType": "number",
"label": "number",
"value": 140
},
{
"fieldType": "string",
"label": "string",
"value": "James Kitchener"
},
{
"fieldType": "alphanumeric",
"label": "alphanumeric",
"value": "123 ABC"
},
{
"fieldType": "date",
"label": "date",
"value": "12/20/2011"
},
{
"fieldType": "decimal",
"label": "decimal",
"value": "23.55"
}
]
},
{
"id":"3",
"cells": [
{
"fieldType": "image",
"label": "image",
"value": "<img src=icon.gif>"
},
{
"fieldType": "number",
"label": "number",
"value": 657
},
{
"fieldType": "string",
"label": "string",
"value": "Loo Gatner"
},
{
"fieldType": "alphanumeric",
"label": "alphanumeric",
"value": "123 XYZ"
},
{
"fieldType": "date",
"label": "date",
"value": "12/20/2011"
},
{
"fieldType": "decimal",
"label": "decimal",
"value": "23.55"
}
]
},
{
"id":"4",
"cells": [
{
"fieldType": "image",
"label": "image",
"value": "<img src=icon.gif>"
},
{
"fieldType": "number",
"label": "number",
"value": 1290
},
{
"fieldType": "string",
"label": "string",
"value": "William Parker"
},
{
"fieldType": "alphanumeric",
"label": "alphanumeric",
"value": "123 FGH"
},
{
"fieldType": "date",
"label": "date",
"value": "12/20/2011"
},
{
"fieldType": "decimal",
"label": "decimal",
"value": "23.55"
}
]
}
]
}
}
}
}
{
“mypage”:{
“室外机”:{
“第页”:“1”,
“总计”:“2”,
“记录”:“2”,
“内部包装”:{
“行”:[
{
“id”:“1”,
“细胞”:[
{
“字段类型”:“图像”,
“标签”:“图像”,
“值”:”
},
{
“字段类型”:“编号”,
“标签”:“编号”,
“价值”:100
},
{
“字段类型”:“字符串”,
“标签”:“字符串”,
“价值”:“詹姆斯·基斯纳尔”
},
{
“字段类型”:“字母数字”,
“标签”:“字母数字”,
“价值”:“77华尔街”
},
{
“字段类型”:“日期”,
“标签”:“日期”,
“价值”:“12/20/2011”
},
{
“字段类型”:“十进制”,
“标签”:“十进制”,
“值”:“23.55”
}
]
},
{
“id”:“2”,
“细胞”:[
{
“字段类型”:“图像”,
“标签”:“图像”,
“值”:”
},
{
“字段类型”:“编号”,
“标签”:“编号”,
“价值”:140
},
{
“字段类型”:“字符串”,
“标签”:“字符串”,
“价值”:“詹姆斯·基奇纳”
},
{
“字段类型”:“字母数字”,
“标签”:“字母数字”,
“值”:“123 ABC”
},
{
“字段类型”:“日期”,
“标签”:“日期”,
“价值”:“12/20/2011”
},
{
“字段类型”:“十进制”,
“标签”:“十进制”,
“值”:“23.55”
}
]
},
{
“id”:“3”,
“细胞”:[
{
“字段类型”:“图像”,
“标签”:“图像”,
“值”:”
},
{
“字段类型”:“编号”,
“标签”:“编号”,
“价值”:657
},
{
“字段类型”:“字符串”,
“标签”:“字符串”,
“值”:“Loo Gatner”
},
{
“字段类型”:“字母数字”,
“标签”:“字母数字”,
“值”:“123 XYZ”
},
{
“字段类型”:“日期”,
“标签”:“日期”,
“价值”:“12/20/2011”
},
{
“字段类型”:“十进制”,
“标签”:“十进制”,
“值”:“23.55”
}
]
},
{
“id”:“4”,
“细胞”:[
{
“字段类型”:“图像”,
“标签”:“图像”,
“值”:”
},
{
“字段类型”:“编号”,
“标签”:“编号”,
“价值”:1290
},
{
“字段类型”:“字符串”,
“标签”:“字符串”,
“价值”:“威廉·帕克”
},
{
“字段类型”:“字母数字”,
“标签”:“字母数字”,
“值”:“123 FGH”
},
{
“字段类型”:“日期”,
“标签”:“日期”,
“价值”:“12/20/2011”
},
{
“字段类型”:“十进制”,
“标签”:“十进制”,
“值”:“23.55”
}
]
}
]
}
}
}
}
JQGrid定义
$(function (){
var getValueByName = function (cells, cellItem) {
var i, count = cells.length, item;
for (i = 0; i < count; i += 1) {
item = cells[i];
if (item.label === cellItem) {
return item.value;
}
}
return '';
};
$("#myjqgrid").jqGrid({
url: "jqgrid.json",
datatype: "json",
contentType: "application/x-javascript; charset=utf-8",
colNames:['Image','Number', 'String', 'Alphanumeric','Date','Decimal'],
colModel:[
{name:'image',index:'image',jsonmap:function(obj){return getValueByName(obj.cells, "image");}, width:150, align:"center"},
{name:'number',index:'number',jsonmap:function(obj){return getValueByName(obj.cells, "number");}, width:150, align:"left", sortable:true},
{name:'string',index:'string',jsonmap:function(obj){return getValueByName(obj.cells, "string");}, width:150, align:"left", sortable:true},
{name:'alphanumeric',index:'alphanumeric',jsonmap:function(obj){return getValueByName(obj.cells, "alphanumeric");}, width:200, align:"left", sortable:true},
{name:'date',index:'date',jsonmap:function(obj){return getValueByName(obj.cells, "date");}, width:150,align:"left", sortable:true},
{name:'decimal',index:'decimal',jsonmap:function(obj){return getValueByName(obj.cells, "decimal");}, width:150,align:"left", sortable:true},
],
jsonReader: {
root: "mypage.outerwrapper.innerwrapper.rows",
page: "mypage.outerwrapper.page",
total: "mypage.outerwrapper.total",
records: "mypage.outerwrapper.records",
repeatitems: false
},
rowNum:2,
rowList:[2, 4],
pager: '#Pager',
recordpos: 'left',
multiboxonly:true,
viewrecords: true,
sortorder: "desc",
multiselect: true,
scrolloffset: 0,
loadonce: true,
sortable: true,
sorttype: "text",
cache: true,
height: "120px"
});
$("#myjqgrid").jqGrid('navGrid','#Pager',{add:false,del:false,edit:false,position:'right'});
$("#myjqgrid").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
});
$(函数(){
var getValueByName=函数(单元格,单元格项){
变量i,计数=单元格。长度,项目;
对于(i=0;i