这是我之前关于将列添加到基于jqgrid的表中的问题的补充。这里是我的新JS代码:
var col_names = ['First', 'Second', 'Third', 'Fourth', 'Fifth'];
var col_model = [
{name:'invid', index:'invid', width:100},
{name:'invdate', index:'invdate', width:90},
{name:'amount', index:'amount', width:80, align:'right'},
{name:'tax', index:'tax', width:80, align:'right'},
{name:'total', index:'total', width:80, align:'right'},
];
function createGrid()
{
var handle = $("#list").jqGrid({
url:'data.xml',
datatype: 'xml',
mtype: 'GET',
colNames: col_names,
colModel : col_model,
});
}
现在我打电话
createGrid();
文档加载后,一切正常。现在,我想添加一个新列(包含空数据)并重新加载jqgrid:
$("#add_column").click(function() {
$('#list').trigger("DestroyGrid"); // Also tried UnloadGrid
col_names.push('New');
col_model.push({name: 'test', index: 'test', width: 100});
createGrid(); // And recreate grid
});
但什么也没发生,为什么?
UPD
$("#add_column").click(function() {
col_names.push('New');
col_model.push({name: 'test', index: 'test', width: 100});
$('#list').trigger("reloadGrid");
});
同样的情况
UPD2
我试过这些:
ajaxGridOptions: {cache: false},
loadonce:false
没有改变情况。