footerdata如何设置jqgrid设置动态列
how footerdata set jqgrid set dynmaic column
iam 创建 jqgrid 动态但我有问题。当创建页脚 jqgrid
call function sumarValores() for footer in loadComplete
but dont know global when use $self.jqGrid
Must use Price_Num instead of global ;but I do not want use Price_Num direct in $self.jqGrid
iam want create dynmamic footer.
dataArray = [
{ id_R: 1, Name_c: "dummy1", AddDate_D: "1394/07/27", Price_Num: "10000" },
{ id_R: 2, Name_c: "dummy2", AddDate_D: "1394/07/28", Price_Num: "120000" },
];
这是我的代码
$('#list').jqGrid({
caption: "",
datatype: 'local',
colNames: getColNames(dataArray[0]),
colModel: getColModels(dataArray[0]),
footerrow : true,
loadComplete: function () {
sumarValores($(this))
},
});
function sumarValores($self) {
var sumaHa = 0;
var columnNames = jQuery("#list").jqGrid('getGridParam', 'colNames');
var global;
for (var z = 0; z < columnNames.length; z++) {
var colN = columnNames[z];
if (colN == "Price")
{
colN = colN.concat('_Num');
global = colN;
var sumCanceled = $self.jqGrid("getCol", colN, false, "sum");
break;
}
}
alert(colN);
global ='Price_Num';
$self.jqGrid("footerData", "set", {
global : sumCanceled,
});
}
为了能够在页脚中书写,您需要有页脚行。请确认您在 jqGrid 中使用了 footerrow: true
选项。
我在这里看到的问题是您无法按照您的方式设置对象 属性。
global ='Price_Num';
$self.jqGrid("footerData", "set", {
global : sumCanceled,
});
要克服这个你可以做到
global ='Price_Num';
var footer = {};
footer[global] = sumCanceled;
$self.jqGrid("footerData", "set", footer );
希望对您有所帮助
iam 创建 jqgrid 动态但我有问题。当创建页脚 jqgrid
call function sumarValores() for footer in loadComplete but dont know global when use $self.jqGrid Must use Price_Num instead of global ;but I do not want use Price_Num direct in $self.jqGrid iam want create dynmamic footer.
dataArray = [ { id_R: 1, Name_c: "dummy1", AddDate_D: "1394/07/27", Price_Num: "10000" }, { id_R: 2, Name_c: "dummy2", AddDate_D: "1394/07/28", Price_Num: "120000" },
]; 这是我的代码
$('#list').jqGrid({
caption: "",
datatype: 'local',
colNames: getColNames(dataArray[0]),
colModel: getColModels(dataArray[0]),
footerrow : true,
loadComplete: function () {
sumarValores($(this))
},
});
function sumarValores($self) {
var sumaHa = 0;
var columnNames = jQuery("#list").jqGrid('getGridParam', 'colNames');
var global;
for (var z = 0; z < columnNames.length; z++) {
var colN = columnNames[z];
if (colN == "Price")
{
colN = colN.concat('_Num');
global = colN;
var sumCanceled = $self.jqGrid("getCol", colN, false, "sum");
break;
}
}
alert(colN);
global ='Price_Num';
$self.jqGrid("footerData", "set", {
global : sumCanceled,
});
}
为了能够在页脚中书写,您需要有页脚行。请确认您在 jqGrid 中使用了 footerrow: true
选项。
我在这里看到的问题是您无法按照您的方式设置对象 属性。
global ='Price_Num';
$self.jqGrid("footerData", "set", {
global : sumCanceled,
});
要克服这个你可以做到
global ='Price_Num';
var footer = {};
footer[global] = sumCanceled;
$self.jqGrid("footerData", "set", footer );
希望对您有所帮助