jQWidgets Forums

jQuery UI Widgets Forums Grid Fail to export aggregate value to MS Excel

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 12 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Fail to export aggregate value to MS Excel #12626

    soonkoh
    Member

    Hi,
    I have a grid which will calculate the total amount and display at the bottom once it is loaded. After I have filtered the grid, the total amount displayed at the bottom is a new value which was the sum from the filtered rows above.

    When I try to export to excel, both the filtered rows and total amount were exported but the value of the total amount was not the sum of the filtered rows but it is the sum of the ALL the rows. Any idea on how to solve this?

    $(document).ready(function () {
    // prepare the data
    //var theme = ‘energyblue’;
    var theme = getTheme();
    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘deliverable_id’, type: ‘number’},
    { name: ‘expected_shipment’, type: ‘string’},
    { name: ‘name’ },
    { name: ‘model’ },
    { name: ‘customer_po_no’, type: ‘string’ },
    { name: ‘month_booked’, type: ‘string’ },
    { name: ‘quantity’, type:’number’},
    { name: ‘amount’, type:’number’}
    ],
    id: ‘deliverable_id’,
    url: ‘backlog_datasource.php’
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    // initialize jqxGrid
    $(“#jqxgrid”).jqxGrid(
    {
    width: 970,
    height:500,
    sortable: true,
    columnsresize: true,
    source: dataAdapter,
    showfilterrow: true,
    filterable: true,
    showstatusbar: true,
    statusbarheight: 25,
    altrows: true,
    showaggregates: true,
    theme: theme,
    enabletooltips: true,
    selectionmode: ‘multiplecellsextended’,
    columns: [
    { text: ‘ID’, datafield: ‘deliverable_id’, width:50, cellsformat: ‘n’, filterable: false },
    { text: ‘Expected Shipment’, filterable: true, datafield: ‘expected_shipment’, width:120, cellsalign:’center’ },
    { text: ‘Customer’, filtertype: ‘textbox’, datafield: ‘name’, filterable: true, width:100, cellsalign:’left’},
    { text: ‘Item’, datafield: ‘model’, filtertype: ‘checkedlist’, width:120, cellsalign:’center’},
    { text: ‘Customer PO.’, filterable: true, datafield: ‘customer_po_no’, width:200},
    { text: ‘Month Booked’, filterable: true, datafield: ‘month_booked’, width:120, cellsformat: ‘n’, cellsalign:’center’},
    { text: ‘Quantity’, filterable: false, datafield: ‘quantity’, width:120, cellsformat: ‘n’, cellsalign:’right’, aggregates: [{ ‘∑’:
    function (aggregatedValue, currentValue, column, record) {
    var total = currentValue;
    return aggregatedValue + total;
    }
    }]},
    { text: ‘Amount’, filterable: false, datafield: ‘amount’, width:120, cellsformat: ‘n’, cellsalign:’right’,aggregates: [{ ‘∑’:
    function (aggregatedValue, currentValue, column, record) {
    var total = currentValue;
    return aggregatedValue + total;
    }
    }]}

    ]
    });
    $(‘#clearfilteringbutton’).jqxButton({ height: 25, theme: theme });
    $(‘#clearfilteringbutton’).click(function () {
    $(“#jqxgrid”).jqxGrid(‘clearfilters’);
    });
    $(“#excelExport”).jqxButton({ theme: theme });
    $(“#excelExport”).click(function () {
    $(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’, ‘jqxGrid’);
    });

    });

    Fail to export aggregate value to MS Excel #12630

    Peter Stoev
    Keymaster

    Hi soonkoh,

    We will not be able to test your code without sample data. Exporting of filtered data and aggregates works as expected on our side, so I would request for a complete sample which demonstrates your scenario. You may send it to support@jqwidgets.com. In addition, make sure that you use the latest version of jQWidgets. Btw. There’s already ‘sum’ aggregate built-in the widget.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.