jQuery UI Widgets Forums Grid Any step-by-step guides for: Grid?

This topic contains 1 reply, has 2 voices, and was last updated by  admin 1 week, 2 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Any step-by-step guides for: Grid? #136489

    sande
    Participant

    I’m using jqxGrid in jQuery with a JSON data source. How can I add a summary row that calculates totals only for the currently visible rows after filtering?

    Any step-by-step guides for: Grid? #136493

    admin
    Keymaster

    Hi,

    In jqxGrid, you can calculate summaries only for the currently visible (filtered) rows by using a custom aggregates function instead of the built-in “sum” aggregate. The built-in aggregates always use the full data source.

    Here’s the correct approach:

    
    $("#grid").jqxGrid({
        showstatusbar: true,
        statusbarheight: 30,
        showaggregates: true,
    });
    
    columns: [
        {
            text: 'Amount',
            datafield: 'amount',
            width: 150,
            aggregates: [{
                'Total (visible)': function (aggregatedValue, currentValue, column, record) {
                    // This function is called only for visible rows
                    return aggregatedValue + parseFloat(currentValue || 0);
                }
            }],
            aggregatesrenderer: function (aggregates) {
                return '<div style="padding: 5px; text-align: right;"><b>' +
                    aggregates['Total (visible)'].toFixed(2) +
                    '</b></div>';
            }
        }
    ]

    Best regards,
    Peter Stoev

    jQWidgets Team
    https://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.