Search code examples
javascriptgwtsmartgwtlistgrid

Grouping large data in the ListGrid


i am using SmartGWT, and i have a problem in grouping the lisgGeid when i have large data.
but every thing works fine when i have small data
I have set following properties to grid:

    sheetAnalysisListGrid = new ListGrid();
    sheetAnalysisListGrid.setWidth("800");
    sheetAnalysisListGrid.setHeight(365); 
    sheetAnalysisListGrid.setShowAllRecords(true);
    sheetAnalysisListGrid.setCanEdit(false);
    sheetAnalysisListGrid.setGroupByField(TahaConstants.TCO_REPORT_PARAMETER_CATEGORY);

    sheetAnalysisListGrid.setShowGroupSummary(true);

    sheetAnalysisListGrid.setShowGroupSummaryInHeader(true);
    sheetAnalysisListGrid.setFields(sheetAnalysisFields);
    sheetAnalysisListGrid.setGroupNodeStyle("listGridGroupNode");
    sheetAnalysisListGrid.setGroupIcon("TahaTCOOverview/group.png");
    sheetAnalysisListGrid.setGroupStartOpen(GroupStartOpen.ALL);


    sheetAnalysisListGrid.addGroupByCompleteHandler(new GroupByCompleteHandler() {
        public void onGroupByComplete(GroupByCompleteEvent event) {
            sheetAnalysisListGrid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
        }
    });

Solution

  • i added listgridName.setGroupByMaxRecords(8000);
    

    Maximum number of records to which a groupBy can be applied. If there are more records, grouping will not be available via the default header context menu, and calls to ListGrid.groupBy will be ignored.

    The maximum exists because ListGrid grouping is performed in-browser, hence requires loading of all records that match the current filter criteria before records can be grouped. The default maximum represents a number of records which are safe to load in legacy browsers such as Internet Explorer 8 (modern browsers can handle far more), and is also a good upper limit from the perspective of loading data from a database.

    Going beyond this limit can cause "script running slowly" errors from legacy browsers (as well as high database load). To build an interface for grouping that handles arbitrary data volume, use a TreeGrid with loadDataOnDemand with server-side grouping code.