jqxgrid之外的自定义聚合

时间:2014-02-24 16:04:35

标签: aggregation jqwidget

我得到了TypeError:e为null     ... numberInput.attr( “已禁用”,真)}其他{n.host.removeClass(c.toThemeProperty(“JQX ... 当我试图从jqwidget grid.pls获取聚合值时告诉我我有什么错误,我怀疑这是$("#tblInvoices").jqxGrid('getcolumnaggregateddata', 'gainPrice', ['min', 'max']);

var source ={   
datatype: "json",
url: url,
data: {invoice_id: $("#id").val()},
datafields: [
            { name: 'roundNo' },
            { name: 'engineNo'},
            { name: 'chasiNo'},
            { name: 'model_id'},
            { name: 'gainPrice'},
            { name: 'selingPrice'},
            { name: 'remark'}
            ],


               addrow: function (rowid, rowdata, position, commit) {
                    // synchronize with the server - send insert command
                    var id=$("#id").val();
                    var data = "insert=true&invoice_id="+id+"&"+ $.param(rowdata);
                    $.ajax({
                        dataType: 'json',
                        url: url,
                        data: data,
                        cache: false,
                        success: function (data, status, xhr) {
                            // insert command is executed.
                            commit(true);
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            commit(false);
                        }
                    });
                },//end  add row

                 deleterow: function (rowid, commit) {
                    // synchronize with the server - send delete command
                    var data = "delete=true&" + $.param({ roundNo: rowid });
                    $.ajax({
                        dataType: 'json',
                        url: url,
                        cache: false,
                        data: data,
                        success: function (data, status, xhr) {
                            // delete command is executed.
                            commit(true);
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            commit(false);
                        }
                    });
                },
                updaterow: function (rowid, rowdata, commit) {
                    // synchronize with the server - send update command
                     var id=$("#id").val();
                    var data = "update=true&invoice_id="+id+"&"+ $.param(rowdata);
                    $.ajax({
                        dataType: 'json',
                        url: url,
                        cache: false,
                        data: data,
                        success: function (data, status, xhr) {
                            // update command is executed.
                            commit(true);
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            commit(false);
                        }
                    });
                }
};
 var dataAdapter = new $.jqx.dataAdapter(source);
//..............................................................

$( "#tblInvoices").jqxGrid({
theme: 'darkblue',
source: dataAdapter,
columnsresize: true,
showaggregates: true,
showstatusbar: true,
statusbarheight: 50,
selectionmode: 'singlecell',
editable: true,
columns: [
            { datafield: 'roundNo', text: 'R/N', type: 'text',  width: 60 },
            { datafield: 'engineNo', text: 'Engine No', type: 'text',  width: 100 },
            { datafield: 'chasiNo', text: 'Chasi No', type: 'text',  width: 100 },
            { datafield: 'model_id', text: 'Model No',  type: 'text',  width: 100 },
            { datafield: 'gainPrice', text: 'Gain Price', cellsformat: 'n2',  width: 60 ,aggregates: ['min', 'max']},
            { datafield: 'selingPrice', text: 'Seling Price', type: 'text',  width: 60,aggregates: [{ 'Total':
                          function (aggregatedValue, currentValue) {
                              if (currentValue) {
                                  return aggregatedValue + 1;

                              }
                              return aggregatedValue;
                          }
                      }] },
            { datafield: 'remark', text: 'Remark', type: 'text',  width: 120 }
            ]
});
//end grid loadi..
 var ta = $("#tblInvoices").jqxGrid('getcolumnaggregateddata', 'gainPrice', ['min', 'max']);
   alert(ta.min);

});

1 个答案:

答案 0 :(得分:0)

问题是你在Grid尚未加载和渲染时调用getcolumnaggregateddata。在Grid的ready回调内或在bindingcomplete事件处理程序中调用它,你会得到更好的结果。