0

我创建 jqgrid dynmamic 但我有问题。当创建页脚 jqgrid

在 loadComplete 中为页脚调用函数 sumarValores() 但在使用$self.jqGrid时不知道全局 必须使用 Price_Num 而不是全局;但我不想在$self.jqGrid中直接使用 Price_Num 我 想创建动态页脚。

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,

    });

    }
4

2 回答 2

0

我在这里看到的问题是您无法按照您的方式设置对象属性。

global ='Price_Num';
$self.jqGrid("footerData", "set", {
    global : sumCanceled,

}); 

为了克服这个你可以做

global ='Price_Num';
var footer = {};
footer[global] = sumCanceled;
$self.jqGrid("footerData", "set", footer );

希望这可以帮助

于 2017-10-06T03:03:06.293 回答
0

为了能够在页脚中书写,您需要有页脚行。请确认您footerrow: true在 jqGrid 中使用了选项。

于 2017-10-04T13:14:40.403 回答