如何将值推送到子网格json的Jq网格?

时间:2016-08-03 12:44:30

标签: jquery jqgrid jqgrid-formatter

我使用Jqgrid显示我的数据,我也实现了Subgrid。但在subgrid我有动态付款选项。现在我无法将该动态值绑定到我的行。

我的子网格json是:

[{"ItemCount":2,"shiftNo":"shift 7","RegisterName":"Report","opnAmt":0,"ClsAmt":0,"GroupedPaymentDetails":{"0":{"PayId":1,"PaymentName":"cash","PaidAmount":114.22},"1":{"PayId":2,"PaymentName":"Credit","PaidAmount":1.4},"2":{"PayId":31,"PaymentName":"RapidRMS Gift Card","PaidAmount":0}},"Total":115.62,"OpenDate":"Aug  3 2016  4:42PM","CloseDate":null,"RegisterId":14,"ZId":100,"ShiftStatus":"Open"}]

现在我的子网格代码是

      var pSubGridColumnNames = new Array();
                    pSubGridColumnNames = ['shift #', 'Register Name','Open Date','Close Date','Open Amount', 'Close Amount'];
                    var pSubGridColumnModels = new Array();
                    pSubGridColumnModels = [{ name: 'shiftNo', index: 'shiftNo', width: 70, summaryType: 'count', summaryTpl: '({0}) total', resizable: false, },
                                    { name: 'RegisterName', index: 'RegisterName', width: 70, resizable: false, },
                                    { name: 'OpenDate', index: 'OpenDate', width: 80, resizable: false, },
                                    { name: 'CloseDate', index: 'CloseDate', width: 80, resizable: false, },
                                    { name: 'opnAmt', index: 'opnAmt', width: 70, sorttype: "number", align: "right", resizable: false, formatter: 'number', formatoptions: { decimalPlaces: 2 } },
                                    { name: 'ClsAmt', index: 'ClsAmt', width: 70, sorttype: "number", align: "right", resizable: false, formatter: 'number', formatoptions: { decimalPlaces: 2 } }
                                    ]; // hidden: true ,

    if (SubGridResult.length > 0) {
                    $.each(SubGridResult[0].GroupedPaymentDetails, function (itemIndex, item) {
                  pSubGridColumnNames.push(item.PaymentName.trim());
                        $.each(item, function (key, value) {
                            if (key == "PaidAmount")
                            {
                                pSubGridColumnModels.push({ name: key, index: key, sorttype: "number", width: 70, resizable: false, align: "right", formatoptions: { decimalPlaces: 2 } })
                            }
                        });

                        //pSubGridColumnModels.push({ name: itemIndex, index: itemIndex, sorttype: "number", width: 50, resizable: false, align: "right", formatoptions: { decimalPlaces: 2 } })
                    });
                }



$("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + pager_id + "' class='scroll'></div>");
            jQuery("#" + subgrid_table_id).jqGrid({
                //data: ParsedJson.filter(function (v) { return v[groupColumnName] == jQuery('#tblShiftSummaryReport').jqGrid('getCell', row_id, groupColumnName).trim() }),
                data: SubGridResult,//ParsedJson.filter(function (v) { return v[groupColumnName] == getRemovedCountFormatedValue(jQuery('#tblShiftSummaryReport').jqGrid('getCell', row_id, groupColumnName).trim()) }),
                datatype: "local",
                colNames: pSubGridColumnNames,
                colModel: pSubGridColumnModels,
                rowNum: 100,
                .
                .
                .

。 但这里没有为PaymentName绑定PaidAmount。它显示总是空白。有人可以帮帮我吗?

0 个答案:

没有答案