jQWidgets Forums

jQuery UI Widgets Forums Grid aggregates issue

This topic contains 5 replies, has 2 voices, and was last updated by  Dimitar 12 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • aggregates issue #12294

    DavidSimmons
    Participant

    I am getting an error on my aggregates when a value in the column is blank. is there a way to correct this?

    aggregates issue #12419

    Dimitar
    Participant

    Hello DavidSimmons,

    We were not able to reproduce the reported issue. Please post a code snippet which we may test locally.

    Best Regards,
    Dimitar

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

    aggregates issue #12535

    DavidSimmons
    Participant

    The issue that I have is when no data is returned I get this error in the aggregate..

    object Object

    I also have an issue when the last column value in the list for the aggregate is blank.

    aggregates issue #12559

    Dimitar
    Participant

    Hello DavidSimmons,

    Here is what you might do – when a cell value is not a number (i.e., blank), a 0 value is added to the aggregate. For example:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <title id='Description'>In this sample is demonstrated how to display aggregates in
    jqxGrid.</title>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.aggregates.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
    <script type="text/javascript" src="generatedata.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    var theme = "";
    // my comment
    // prepare the data
    var data = generatedata(0);
    var source =
    {
    localdata: data,
    datatype: "array",
    updaterow: function (rowid, rowdata) {
    // synchronize with the server - send update command
    }
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    // initialize jqxGrid
    $("#jqxgrid").jqxGrid(
    {
    width: 680,
    source: dataAdapter,
    theme: theme,
    showstatusbar: true,
    statusbarheight: 50,
    editable: true,
    showaggregates: true,
    selectionmode: 'singlecell',
    columns: [
    { text: 'First Name', columntype: 'textbox', datafield: 'firstname', width: 90 },
    { text: 'Last Name', datafield: 'lastname', columntype: 'textbox', width: 90 },
    { text: 'Product', datafield: 'productname', width: 170,
    aggregates: ['count',
    { 'Cappuccino Items':
    function (aggregatedValue, currentValue) {
    if (currentValue == "Cappuccino") {
    return aggregatedValue + 1;
    }
    return aggregatedValue;
    }
    }
    ]
    },
    { text: 'In Stock', datafield: 'available', columntype: 'checkbox', width: 125,
    aggregates: [{ 'In Stock':
    function (aggregatedValue, currentValue) {
    if (currentValue) {
    return aggregatedValue + 1;
    }
    return aggregatedValue;
    }
    },
    { 'Not In Stock':
    function (aggregatedValue, currentValue) {
    if (!currentValue) {
    return aggregatedValue + 1;
    }
    return aggregatedValue;
    }
    }
    ]
    },
    { text: 'Quantity', datafield: 'quantity', width: 85, cellsalign: 'right', cellsformat: 'n2', aggregates: ['min', 'max'],
    aggregatesrenderer: function (aggregates) {
    var renderstring = "";
    $.each(aggregates, function (key, value) {
    var name = key == 'min' ? 'Min' : 'Max';
    if (isNaN(value)) {
    value = 0;
    renderstring = "";
    }
    renderstring += '<div style="position: relative; margin: 4px; overflow: hidden;">' + name + ': ' + value + '</div>';
    });
    return renderstring;
    }
    },
    { text: 'Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum', 'avg'] }
    ]
    });
    });
    </script>
    </head>
    <body class='default'>
    <div id='jqxWidget'>
    <div id="jqxgrid">
    </div>
    </div>
    </body>
    </html>

    Best Regards,
    Dimitar

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

    aggregates issue #12678

    DavidSimmons
    Participant

    Can you tell me what value is? It seem to be an object so this does not work. It is returning all 0.

    if (isNaN(value)) {
    value = 0;
    renderstring = “”;
    }

    aggregates issue #12706

    Dimitar
    Participant

    Hi DavidSimmons,

    The parameter value is the value of the key parameter, which may be min, max, sum, etc.

    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.