无法使用用户数据信息填充 JqGrid 页脚
我很难使用 jqGrid 显示页脚信息。我已按照所有必要的步骤设置页脚。服务器请求基于某些过滤条件。服务器返回带有适当“userdata”信息的 json。以下是 JSON 和 javascript 信息。
{
"timeatt": [
{
"empnum" : "12345",
"name" : "ABCDEFG",
"shift" : "1",
"postdate" : "12/27/10",
"regular" : "40",
"ot" : "8",
"dbltime" : "0",
"holiday" : "0",
"vacation" : "0",
"payrate" : "0"
},
{
"empnum" : "67890",
"name" : "HIJKLMN",
"shift" : "1",
"postdate" : "12/27/10",
"regular" : "32",
"ot" : "0",
"dbltime" : "0",
"holiday" : "0",
"vacation" : "8",
"payrate" : "0"
}
],
"userdata": {
"name": "Totals",
"regular": "72",
"ot": "8",
"dbltime": "0",
"vacation": "8",
"holiday": "0"
},
"totalrecords" : "2"
}
jQGrid 信息
$("#empinfo").jqGrid({
datatype:'json',
colNames:['Clock#','Name','PostDate','Shift','Regular','Over Time','Dbl Time',
'Vacation','Holiday'],
colModel:[{name:'empnum', index:'empNum', width:60},
{name:'name', index:'name', width:200},
{name:'postdate', index:'postdate', width:60,editable:false,
hidden:true,editrules:{edithidden:false}},
{name:'shift', index:'shift', width:60,editable:true,edittype:'text'},
{name:'regular', index:'regular', width:70,editable:true,
edittype:'text',align:"right", formatter: 'number'},
{name:'ot', index:'ot', width:70,editable:true,edittype:'text',
align:"right", formatter: 'number'},
{name:'dbltime', index:'dltime', width:70,editable:true,
edittype:'text',align:"right", formatter: 'number'},
{name:'vacation', index:'vacation', width:70,editable:true,
edittype:'text',align:"right", formatter: 'number'},
{name:'holiday', index:'holiday', width:70,editable:true,
edittype:'text',align:"right", formatter: 'number'}],
scroll:1,
scrollRows:true,
height:300,
editurl:'clientArray',
footerrow:true,
userDataOnFooter:true,
altRows:true,
onSelectRow: function(rowNum){
if (rowNum && rowNum != lastSel) {
$("#empinfo").saveRow(lastSel);
}
$("#empinfo").editRow(rowNum,true);
lastSel = rowNum;
},
});
我尝试了 jqGrid 演示中列出的所有内容,但由于某种原因,“userdata”信息没有被填充。有人可以帮助我吗?
谢谢 玛尔加班杜
I am having a tough time to display footer information using jqGrid. I have followed all the necessary steps to setup footer. The server request is based on some filter condition. The server returns a json with appropriate "userdata" information. Following are the JSON and javascript information.
{
"timeatt": [
{
"empnum" : "12345",
"name" : "ABCDEFG",
"shift" : "1",
"postdate" : "12/27/10",
"regular" : "40",
"ot" : "8",
"dbltime" : "0",
"holiday" : "0",
"vacation" : "0",
"payrate" : "0"
},
{
"empnum" : "67890",
"name" : "HIJKLMN",
"shift" : "1",
"postdate" : "12/27/10",
"regular" : "32",
"ot" : "0",
"dbltime" : "0",
"holiday" : "0",
"vacation" : "8",
"payrate" : "0"
}
],
"userdata": {
"name": "Totals",
"regular": "72",
"ot": "8",
"dbltime": "0",
"vacation": "8",
"holiday": "0"
},
"totalrecords" : "2"
}
jQGrid Information
$("#empinfo").jqGrid({
datatype:'json',
colNames:['Clock#','Name','PostDate','Shift','Regular','Over Time','Dbl Time',
'Vacation','Holiday'],
colModel:[{name:'empnum', index:'empNum', width:60},
{name:'name', index:'name', width:200},
{name:'postdate', index:'postdate', width:60,editable:false,
hidden:true,editrules:{edithidden:false}},
{name:'shift', index:'shift', width:60,editable:true,edittype:'text'},
{name:'regular', index:'regular', width:70,editable:true,
edittype:'text',align:"right", formatter: 'number'},
{name:'ot', index:'ot', width:70,editable:true,edittype:'text',
align:"right", formatter: 'number'},
{name:'dbltime', index:'dltime', width:70,editable:true,
edittype:'text',align:"right", formatter: 'number'},
{name:'vacation', index:'vacation', width:70,editable:true,
edittype:'text',align:"right", formatter: 'number'},
{name:'holiday', index:'holiday', width:70,editable:true,
edittype:'text',align:"right", formatter: 'number'}],
scroll:1,
scrollRows:true,
height:300,
editurl:'clientArray',
footerrow:true,
userDataOnFooter:true,
altRows:true,
onSelectRow: function(rowNum){
if (rowNum && rowNum != lastSel) {
$("#empinfo").saveRow(lastSel);
}
$("#empinfo").editRow(rowNum,true);
lastSel = rowNum;
},
});
I tried everything listed in the jqGrid demo but for somereason, the "userdata" information is not getting populated. Can anybody help me ?
Thanks
SMargabandhu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您应该删除代码末尾
});
之前的逗号。您的代码肯定不完整。例如url
参数未定义,所以我认为逗号来自实际代码的减少。关于你的主要问题。您应该在 jqGrid 定义中包含 jsonReader 才能显示您发布的 JSON 数据。
jsonReader
可以如下所示:之后将显示数据,包括
'userdata'
将显示(请参阅 此处)First of all you should remove comma before
});
at the end of your code. Your code is sure not full. For exampleurl
parameter is not defined so I suppose the comma come from the reduction of real code.About your main problem. You should include jsonReader in the jqGrid definition to be able to display the JSON data which you posted. The
jsonReader
can be following:After that the data will be displayed inclusive the
'userdata'
will be displayed (see here)(colModel) 中的列的相同名称以返回 userdata,例如:
userdata = new { hours= lista.Sum(x => x.Horas).ToString(), function= "Total HH:" }
the same name of the columns in (colModel) to return userdata, example:
userdata = new { hours= lista.Sum(x => x.Horas).ToString(), function= "Total HH:" }