JLynch7 / SlickGrid

A lightning fast JavaScript grid/spreadsheet
https://github.com/jlynch7/SlickGrid/wiki
MIT License
89 stars 76 forks source link

Grouping with frozenBottom:true not working? #81

Open marbetschar opened 9 years ago

marbetschar commented 9 years ago

At the bottom of the grid I'd like to add 4 frozen rows which contains the total of the whole grid calculated by using setGrouping on the slick's dataView:

dataView = new Slick.Data.DataView();
_getItemMetadata = dataView.getItemMetadata;
dataView.getItemMetadata = function(row){
    var metadata = _getItemMetadata(row);

    if( row > (dataView.getLength() - 4) ){
        metadata = $.extend(true,metadata,{
            columns:{
                ticker:{
                    colspan:4
                }
            }
        });
}

if(row == (dataView.getLength() - 1)){
    metadata = $.extend(true,metadata,{
        columns:{
            ticker:{
                formatter:function(){
                    return '<strong>Total Vermögen in CHF</strong>';
                }
            }
        }
    });
}

return metadata;
};

dataView.setItems(data);
dataView.setGrouping({
    aggregators:aggregators  //these aggregators are collected dynamically
});

dataView.beginUpdate();
    dataView.addItem($.extend({ id:'titles',ticker:'Total Titel in CHF',groupName:'Total', colspan:3 }, dataView.getGroups()[0].totals.sum ));
    dataView.addItem({ id:'cash',ticker:'Cash in CHF',groupName:'Total', colspan:3 });
dataView.endUpdate();
dataView.setGrouping({
    getter:'groupName',
    formatter:function(g){ return ''; },
    aggregators:aggregators
});

var options = {
    enableColumnReorder: false,
    showHeaderRow: true,
    headerRowHeight: 24,
    frozenBottom: true,
    frozenColumn: 3,
    frozenRow: 4
};

frozenGrid = new Slick.Grid('#grid-kunden-depots', dataView, columns, options);

Which should result in the following

total-correct

But sometimes, the grouping got messed up and the total rows are inside of the grid, not at the bottom: total-messed-up

Any ideas whats wrong?