首先,我想说清楚,我知道在这些论坛中还有其他类似于我的帖子。不幸的是,使用它们我无法使addRowData正常工作。我有一个这样定义的表格:无法让jqgrid addRowData正常工作
var tableDef = {
scroll: 1,
url:"/SCSalesDataReport/showReport/getSalesReportJSON",
datatype: "json",
colNames:['id','Type', 'Name', 'Total','In','Out'],
colModel:[
{ name: 'id', index: 'testid', hidden: true},
{name:'type',index:'type', width:10, sortable:true},
{name:'name',index:'name', width:40, sortable:true},
{name:'total',index:'total', width: 10, sortable:false},
{name:'in',index:'in', width:10, sortable:true},
{name:'out',index:'out', width:10, sortable:true}, ],
rowNum:100,
mtype: "GET",
sortname: 'id',
viewrecords: true,
height : '500',
altRows: true,
autowidth: true,
};
以及它的价值,那就是按照人们的期望工作和填充表格。不幸的是,使用我在这些论坛中看到的一些帖子,一旦它创建完成,我就无法将数据添加到表格中。我试图通过一个链接添加一行,就像这样:连接到这个标签
window.onload = function() {
var a = document.getElementById("addRow");
a.onclick = function() {
var count = $("#grid").getGridParam("reccount");
var newRowData = {'id':count, 'Type':"ADDEDTYPE", 'Name':"Insert 1", 'Total':"10",'In':"50",'Out':"40"};
jQuery("#myTable").addRowData("id", newRowData);
jQuery("#myTable").trigger("reloadGrid");
return false;
}
}
:
<a id="addRow" href="www.google.com">Oh please, for the love of all that is holy... add a row!</a>
如果有人可以帮我找出我在做什么错了,那大概是赞赏。我强烈怀疑我只是在做一些愚蠢的事情,或者忽视简单的事情。
在此先感谢。