jQuery UI Widgets Forums Grid aggregates text

This topic contains 5 replies, has 3 voices, and was last updated by  Dimitar 8 years, 7 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • aggregates text #15429

    mkdodos
    Participant

    Hi,
    When write the code
    aggregates: [‘sum’]
    it shows “Sum:59820”
    How to change the text “Sum” to another word?
    Thanks,
    Mark

    aggregates text #15449

    Dimitar
    Participant

    Hello Mark,

    This can be achieved by using aggregatesrenderer. Here is an example of a column definition:

                      { text: 'Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'],
    aggregatesrenderer: function (aggregates, column, element, summaryData) {
    var renderstring = "<div class='jqx-widget-content jqx-widget-content-" + theme + "' style='float: left; width: 100%; height: 100%;'>";
    $.each(aggregates, function (key, value) {
    renderstring += '<div style="position: relative; margin: 6px; text-align: right; overflow: hidden;">All: ' + value + '</div>';
    });
    renderstring += "</div>";
    return renderstring;
    }
    }

    You may also find the Aggregates Renderer helpful.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    aggregates text #85865

    xixo
    Participant

    Hello.

    When I try the given example I get this message:

    Uncaught Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch.

    Any ideas? Thanks.

    aggregates text #85877

    Dimitar
    Participant

    Hello xixo,

    Please note that the above example has been posted more than three years ago and may not be compatible with the latest version of jQWidgets (4.1.2). The aggregatesrenderer functionality is demonstrated in the following example: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/aggregatesrenderer.htm?light. If you continue to experience any issues, please specify what your requirement is and share your jqxGrid-related source code for us to review.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    aggregates text #85888

    xixo
    Participant

    Ok.

    Just tested the example given in the demo page, and the error is the same.
    Here’s my code:

    var estruct = {
        datafields: [
            { name: 'name', type: 'string' },
            { name: 'ly', type: 'decimal' },
            { name: 'lyytd', type: 'decimal' },
            { name: 'rdg', type: 'decimal' }
        ]
    };
    
    var sourceanl = estruct;
    
    var dataAdaptersourceanl = new $.jqx.dataAdapter(sourceanl);
    
    function createanl() {
        $("#jqxgridanl").jqxGrid({
            source: dataAdaptersourceanl,
            theme: 'Metro',
            height: 600,
            width: '100%',
            sortable: true,
            columnsresize: true,
            showaggregates: true,
            showstatusbar: true,
            statusbarheight: 25,
            altrows: true,
            showtoolbar: true,
            columns: [
                        { text: 'Name', dataField: 'name', width: 150 },
                        { text: 'LY', dataField: 'ly', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'c0'
                            , aggregates: [{
                                '':
                                 function (aggregatedValue, currentValue, column, record) {
                                     return aggregatedValue + currentValue;
                                 }
                            }]
                        },
                        { text: 'LYYTD', dataField: 'lyytd', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'c0'
                            , aggregates: [{
                                '':
                                 function (aggregatedValue, currentValue, column, record) {
                                     return aggregatedValue + currentValue;
                                 }
                            }]
                        },
                        {
                            text: 'R/D/G', dataField: 'rdg', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'c0'
                            , aggregates: ['sum', 'avg']
                            , aggregatesrenderer: function (aggregates, column, element, summaryData) {
                                var renderstring = "<div class='jqx-widget-content jqx-widget-content-Metro' style='float: left; width: 100%; height: 100%;'>";
                                $.each(aggregates, function (key, value) {
                                    var name = key == 'sum' ? 'Sum' : 'Avg';
                                    var color = 'green';
                                    if (key == 'sum' && summaryData['sum'] < 650) {
                                        color = 'red';
                                    }
                                    if (key == 'avg' && summaryData['avg'] < 4) {
                                        color = 'red';
                                    }
                                    renderstring += '<div style="color: ' + color + '; position: relative; margin: 6px; text-align: right; overflow: hidden;">' + name + ': ' + value + '</div>';
                                });
                                renderstring += "</div>";
                                return renderstring;
                        }
                    ]
        });
    
        var localizationobj = {};
        localizationobj.currencysymbol = " €";
        localizationobj.currencysymbolposition = "after";
        $("#jqxgridanl").jqxGrid('localizestrings', localizationobj);
    
    }

    Thanks.

    aggregates text #85921

    Dimitar
    Participant

    Hello xixo,

    Are you sure this issue is directly related to aggregatesrenderer? Please move the call to localizestrings to the grid’s ready callback to ensure the grid has finished loading when the method is invoked. If the issue persists, please share some sample data so that we can test your example locally. Please also make sure you are using the latest version of jQWidgets (4.1.2).

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.