【发布时间】:2011-11-07 19:33:36
【问题描述】:
我正在尝试向我的数据源添加一个项目,然后根据this answer 重新加载网格。网格加载正常。 addItemToGrid 被调用了几次,我正在验证底层 tableSrc 对象是否被添加,但网格保持不变。
var tableSrc = { "rows": [
{ "title": "Title1", "subtitle": "subTitle", "authors": ["a1", "a2", "a3"] },
{ "title": "Title2", "subtitle": "subtitle", "authors": ["X", "Y"] },
{ "title": "Title3", "subtitle": "subTitle", "authors": ["1", "2", "3", "4"]}]
};
targetGrid = $("#jqGridElement").jqGrid({
datastr: tableSrc,
jsonReader: { repeatitems: false },
datatype: "jsonstring",
colNames: ['title', 'subtitle'],
colModel: [
{ name: 'title', index: 'title', width: 55 },
{ name: 'subtitle', index: 'subtitle'}],
height: 'auto',
gridview: true
});
function addItemToGrid() {
tableSrc.rows.push({ "title": "NEW", "subtitle": "HELLO", "authors": ["1", "2", "3", "4"] });
$("#jqGridElement").trigger('reloadGrid');
//$("#jqGridElement").jqGrid('reloadGrid');
}
【问题讨论】:
-
看看这个:[jqGrid 解决方案][1] [1]:stackoverflow.com/questions/1297044/…
-
看起来该链接说要使用以下命令清除网格:
$("#jqGridElement").trigger('gridUnload');- 但这似乎没有任何作用......
标签: jquery-plugins jqgrid jqgrid-asp.net