jQWidgets Forums

jQuery UI Widgets Forums Grid Filterrow + custom aggregates renderer

This topic contains 1 reply, has 1 voice, and was last updated by  angelocavallet 11 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Filterrow + custom aggregates renderer #29186

    Hello, sorry for my bad English

    I have some problem when I use the filterrow in a grid with custom aggregatesrenderer. When I change the filter value, the aggregate does not appear. Can anyone help me with this?

    I added the filterrow in ‘aggregates.htm’ demo so if you remove a filter after that you add it, aggregates doesn’t appear.

    In this sample is demonstrated how to display aggregates in jqxGrid.

    $(document).ready(function () {
    var theme = “”;
    // my comment
    // prepare the data
    var data = generatedata(200);

    var source =
    {
    localdata: data,
    datatype: “array”,
    datafields:
    [
    { name: ‘firstname’, type: ‘string’ },
    { name: ‘lastname’, type: ‘string’ },
    { name: ‘productname’, type: ‘string’ },
    { name: ‘available’, type: ‘bool’ },
    { name: ‘quantity’, type: ‘number’ },
    { name: ‘price’, type: ‘number’ }
    ],
    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,
    filterable: true,
    editable: true,
    showfilterrow: 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, teste) {
    console.log(teste)
    var renderstring = “”;
    $.each(aggregates, function (key, value) {
    var name = key == ‘min’ ? ‘Min’ : ‘Max’;
    renderstring += ‘

    ‘ + name + ‘: ‘ + value +’

    ‘;
    });
    return renderstring;
    }
    },
    { text: ‘Price’, datafield: ‘price’, cellsalign: ‘right’, cellsformat: ‘c2’, aggregates: [‘sum’, ‘avg’] }
    ]
    });
    });

    Filterrow + custom aggregates renderer #29187

    It only happens when I set a filter value with no results

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

You must be logged in to reply to this topic.