Issue with Syncfusion ejGrid and knockout.js when displaying summary rows

724 views Asked by At

I'm having issues using Syncfusion ejGrid and knockout.js when displaying group summary values and either starting with an empty grid or when adding elements to an existing grid dynamically.

Grid setup:

    <div id="Grid" data-bind="ejGrid: {
               dataSource: dataSource, 
               allowGrouping:true, 
               allowSorting:true,
               columns: [{ field: 'OrderID', headerText: 'OrderID' },
                         { field: 'CustomerID', headerText: 'CustomerID' },
                         { field: 'ShipCity', headerText: 'ShipCity' },
                         { field: 'Freight', headerText: 'Freight' },
                         { field: 'EmployeeID', headerText: 'EmployeeID' }
                        ],                    
                showSummary: true,
                summaryRows: [
                            { summaryColumns: [{
                                summaryType: ej.Grid.SummaryType.Sum,
                                displayColumn: 'Freight',
                                dataMember: 'Freight',
                                prefix: 'Total: '
                                }],
                              showCaptionSummary: true,
                              showTotalSummary: false
                            }
                        ],                     
                    }">
    </div>

Initialisation:

var rows = [{
    OrderID: 10248,
    CustomerID: "VINET",
    ShipCity: "Reims",
    Freight: 11.61,
    EmployeeID: 4
}, {
    OrderID: 10250,
    CustomerID: "HANAR",
    ShipCity: "Charleroi",
    Freight: 65.83,
    EmployeeID: 2
}, {
    OrderID: 10251,
    CustomerID: "VICTE",
    ShipCity: "Reims",
    Freight: 41.34,
    EmployeeID: 1
}, {
    OrderID: 10252,
    CustomerID: "SUPRD",
    ShipCity: "Madrid",
    Freight: 51.3,
    EmployeeID: 3
}, {
    OrderID: 10253,
    CustomerID: "HANAR",
    ShipCity: "Rio de Janeiro",
    Freight: 58.17,
    EmployeeID: 3
}];

var source = ko.observableArray(rows);

var gridData = {
    dataSource: source
};

ko.applyBindings(gridData);

Now, the following jsfiddle works fine. That is, if you drag the 'CustomerID' column into the grouping area, the summary values for each group (labelled 'Total') appear fine: http://jsfiddle.net/zxw5sL2m/1/

Now, if the grid is initially empty, and then rows are added, it fails when loading with 'TypeError: r is undefined' in ej.web.all-latest.min.js: http://jsfiddle.net/zxw5sL2m/2/ (Also, this scenario doesn't work if knockout.js is removed: http://jsfiddle.net/ymgkf7r9/ )

Similarly, if the grid is initially non-empty and then rows are added, it loads ok, but then when grouping is applied, it fails with 'TypeError: y is null' in in ej.web.all-latest.min.js: http://jsfiddle.net/zxw5sL2m/3/

The errors go away if the group summary is not included: http://jsfiddle.net/zxw5sL2m/4/

Setting showCaptionSummary: false sort-of works, however each time a new row is added (prior to any grouping), a new summary row is also added at the bottom instead of updating the existing summary row: http://jsfiddle.net/zxw5sL2m/5/

In addition, if the grid is grouped by a column to begin with, and then rows are added, the groups are updated correctly: http://jsfiddle.net/zxw5sL2m/8/ However, if the grid is originally ungrouped, and then grouped later on (either by the user or by calling the gridColumn method), when new rows are added to the grid, the grouping is lost (although strangely the group column name still appears in the group area in the header): http://jsfiddle.net/zxw5sL2m/9/

1

There are 1 answers

0
Prasanna Kumar On BEST ANSWER

For the related queries, We have confirmed that the issue with “Throws script error with grouping with enable caption summary while rendering rows using timeout” is a defect and logged a defect report . The fix for this issue will be included in our Volume 2, Service Pack 1 2015 which has been scheduled to be rolled out at the end of July 2015.

Please contact Syncfusion Support if you have any related questions.

Regards, Prasanna Kumar N.S.V