我在jqPivot中使用jqGrid。
我的数据:
var data = [{
Account: "Tom", Contact: "Mary", KindOfCare: 'Birthday', value: 1, notes: 'Birthday'
}, {
Account: "Tom", Contact: "Mary", KindOfCare: 'Christmas', value: 0, notes: 'Birthday'
}, {
Account: "Tom", Contact: "Mary", KindOfCare: 'New Year', value: 0, notes: 'Birthday'
}, {
Account: "Tom", Contact: "Mia", KindOfCare: 'Birthday', value: 0, notes: 'Birthday'
}, {
Account: "Tom", Contact: "Mia", KindOfCare: 'Christmas', value: 0, notes: 'Birthday'
}, {
Account: "Tom", Contact: "Mia", KindOfCare: 'New Year', value: 0, notes: 'Birthday'
},
{
Account: "Anna", Contact: "David", KindOfCare: 'Birthday', value: 1, notes: 'Birthday'
}, {
Account: "Anna", Contact: "David", KindOfCare: 'Christmas', value: 1, notes: 'Birthday'
}, {
Account: "Anna", Contact: "David", KindOfCare: 'New Year', value: 0, notes: 'Birthday'
}, {
Account: "Selena", Contact: "Bieber", KindOfCare: 'Birthday', value: 0, notes: 'Birthday'
}, {
Account: "Selena", Contact: "Bieber", KindOfCare: 'Christmas', value: 1, notes: 'Birthday'
}, {
Account: "Selena", Contact: "Bieber", KindOfCare: 'New Year', value: 1, notes: 'Birthday'
}];我希望用输入标记替换透视表列的值,例如:如果value =1,则返回复选框选中,如果value = 0,则返回复选框

有什么办法可以做到吗?
发布于 2017-12-22 17:33:05
如果您在模板中设置空字符串,则此代码将起作用。请查看免费的jqGrid文档,什么是模板,以及参数可以接受的可能值
aggregates: [
{ member: "KindOfCare",
template: "",
aggregator: function (options) {
//console.log(options);
//return options.item.value;
if(options.item.value == 1){
return '<input class="center" type="checkbox" checked disabled />';
}
else{
return '<input class="center" type="checkbox" disabled />';
}
}
}
]https://stackoverflow.com/questions/47938129
复制相似问题