0

我得到 TypeError: e is null ...numberInput.attr("disabled",true)}else{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);

});
4

1 回答 1

0

问题是您在 Grid 尚未加载和呈现时调用 getcolumnaggregateddata。在 Grid 的 ready 回调或它的 bindingcomplete 事件处理程序中调用它,您将获得更好的结果。

于 2014-02-25T06:28:54.000 回答