【发布时间】:2011-12-20 16:38:21
【问题描述】:
我正在使用 jqGrid 插件来显示一些数据(本地),所以
$("#myList").jqGrid({
datatype : 'jsonstring',
datastr : getMyJson(),
colNames : ['ID', 'TITLE', 'PROFILE'],
colModel : [{
name : 'Id',
index : 'Id',
width : 50,
sorttype : 'int'
}, {
name : 'Title',
index : 'Title',
width : 100
}, {
name : 'Profile',
index : 'Profile',
width : 80
}],
jsonReader : {
root : "rows",
page : "page",
total : "total",
records : "records",
repeatitems : true,
cell : "cell",
id : "id"
},
autoencode : true,
ignoreCase : true,
autowidth : true,
cache : false,
shrinkToFit : false,
height : 500,
rowNum : 3000,
rowList : [10, 20, 30],
pager : jQuery('#pager1'),
viewrecords : true,
sortable : true,
loadonce : true,
gridview : true,
sortorder : "asc",
multiselect : true,
caption : "My List",
emptyrecords : 'No results'
});
$("#myList").jqGrid('filterToolbar', {
stringResult : true,
searchOnEnter : false
});
问题在于搜索。当我在任何工具栏上输入文本进行搜索时,所有行数据都会消失。我看过这个演示 http://www.trirand.com/blog/jqgrid/jqgrid.html,但我找不到问题所在。
我的网格上是否缺少任何东西?
提前致谢
编辑:
function getMyJson() {
var json;
jQuery.ajaxSetup({
async : false
});
$.post(BIN_ROOT + "getdata.php", function(data, textStatus) {
json = data.Mytable;
}, "json");
jQuery.ajaxSetup({
async : true
});
return json;
}
Json 具有以下格式
{
"errorCode": 0,
"errorDesc": "No Error",
"MyTable": {
"page": 1,
"total": 1,
"records": 12,
"rows": [{
"id": "41",
"cell": ["41", "Title1", "User"]
}, {
"id": "30",
"cell": ["30", "Title1", "Admin"]
}, (...)
}
}
【问题讨论】:
-
我想你的问题的原因可能是来自
getMyJson()的数据,你用它来填充网格。您能否在问题文本中添加测试数据?
标签: jquery search jqgrid local