好的,我认为这是因为当我将sumColumnModel分配给colModel时,sumColumnModel为空,因为sumColumnModel在success函数中只是非空的。那么有什么方法可以从成功函数中获取变量并在colModel中使用它?
我正在使用一个函数来获取我的数据,我正在获取数据。我从data.d获得了这个JSON:
"{"Page":1,
"TotalPages":5.0,
"TotalRecords":122,
"ColumnModel": [
{"name":"Description","sorttype":"string","align":"center"},
{"name":"Matrix","sorttype":"string","align":"center"},
{"name":"AvailableReports","sorttype":"string","align":"center","hidden":true},
{"name":"Classification","sorttype":"string","align":"center","hidden":true}
],
"Submissions":[
{"DateSubmitted":"4/23/2014","DateSampled":null,"Matrix":"Sometype","Status":"Completed","SubmissionId":"001","Description":"description","Company":null,"Classification":null,"AvailableReports":7},
{"DateSubmitted":"4/23/2014","DateSampled":null,"Matrix":"sometype","Status":"Completed","SubmissionId":"002","Description":"description","Company":null,"Classification":null,"AvailableReports":6}
]}"
我目前正在使用这个jsonreader:
jsonReader: {
repeatitems: false,
root: function(obj) { return obj.Submissions; },
page: function(obj) { return obj.Page; },
total: function(obj) { return obj.TotalPages; },
records:function(obj) { return obj.TotalRecords; },
}
我厌倦了提交'提交内容'对于jsonreader中root的值但是没有做到这一点。
我的列模型正在我的ajax函数调用的成功部分进行编辑,以正确显示像这样完成的某些列。
myData.ColumnModel.splice(0, 0,
{ name: "DateSubmitted", label: "Date Submitted", sorttype: "date", align: "center"});
myData.ColumnModel.push(
{ name: "Status", sorttype: "string", align: "center" },
{ name: "SubmissionId", label:"Submission Id", sorttype: "string", align: "center" });
sumColumnModel = myData.ColumnModel;
然后我将sumColumn作为网格的列模型传递。
colModel: sumColumnModel,
知道为什么网格没有被填充?
答案 0 :(得分:0)
所以我最初只是初始化colModel然后根据几个下拉菜单添加/减去它的内容。很高兴知道我是否真的可以从datatype:function
中获得col模型,但此时我只是解决了它。