简体   繁体   中英

Ext JS exclude null values in summary Ext.grid.feature.Summary in grid

I have some null values in my datastore. I am using ftype summary to show the summary row, when it is calculating the summary(min/max) it is considering the null as min/max . Is there any way to exclude the null values and calculate the summary. I have created the grid as below

var grid = Ext.create('Ext.grid.Panel', {
    width: width,
    height: height,
    //frame: true,
    cls: 'gridPadding, x-panel gridPadding x-grid-with-row-lines x-panel-default-framed x-grid',
    id: 'dashboardSearchGrid_' + DivId,
    renderTo: DivId,
    buffered: true,
    store: store,
    plugins: [
        Ext.create('Ext.ux.grid.plugin.GroupingPanel')
    ],
    features: [{
        ftype: 'summary',
        dock: 'bottom'
    }]
});

I had the same issue, i did not found a solution to configure that.

That should work:

You can use a renderer inside your column definiton

renderer: function (value, meta, record) {
   if (value === null || value === "") {
     value = 0;
   }                
return value;
}

Or you can manipulate the data using convert or calculate inside your model definition.

http://docs.sencha.com/extjs/6.0.1/classic/Ext.data.field.Field.html#cfg-convert

I achieved it by modifying the getMin function in ext-all.js source like below

getMin: function(records, field) {
var i = 1,
    len = records.length,
    value, min;

if (len > 0) {
    min = records[0].get(field);
}

for (; i < len; ++i) {
    value = records[i].get(field);
    if(value == null){
        continue;
    }
    if (value < min || min == null) {
        min = value;
    }
}
return min;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM