jQWidgets Forums

jQuery UI Widgets Forums Grid csv export and aggregates

This topic contains 2 replies, has 2 voices, and was last updated by  rharding98 11 years, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • csv export and aggregates #28712

    rharding98
    Participant

    When exporting to CSV the aggregates seem to be shifting one row to the left and are not aligned with the correct row. Is this a known issue and is there a workaround? It works fine in the HTML view.

    csv export and aggregates #28713

    Peter Stoev
    Keymaster

    Hi rharding98,

    We do not find anything not normal in the CSV export.

    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.10.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/jqxgrid.export.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.export.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
    <script type="text/javascript" src="../../scripts/gettheme.js"></script>
    <script type="text/javascript" src="generatedata.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    var theme = getDemoTheme();
    // my comment
    // prepare the data
    var data = generatedata(5);
    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,
    editable: true,
    showaggregates: true,
    ready: function () {
    $("#jqxgrid").jqxGrid('exportdata', 'csv', 'grid');
    },
    selectionmode: 'singlecell',
    columns: [
    { text: 'First Name', columntype: 'textbox', datafield: 'firstname', width: 90 },
    { text: 'Last Name', datafield: 'lastname', columntype: 'textbox', width: 90 },
    { text: 'Quantity', datafield: 'quantity', width: 85, cellsalign: 'right', cellsformat: 'n2', aggregates: [ 'max'],
    aggregatesrenderer: function (aggregates) {
    var renderstring = "";
    $.each(aggregates, function (key, value) {
    var name = key == 'min' ? 'Min' : 'Max';
    renderstring += '<div style="position: relative; margin: 4px; overflow: hidden;">' + name + ': ' + value +'</div>';
    });
    return renderstring;
    }
    }
    ]
    });
    });
    </script>
    </head>
    <body class='default'>
    <div id='jqxWidget'>
    <div id="jqxgrid"></div>
    </div>
    </body>
    </html>

    Result:

    "First Name","Last Name","Quantity"
    "Guylene","Nodier","7"
    "Michael","Davolio","7"
    "Mayumi","Devling","7"
    "Martin","Burke","6"
    "Lars","Bein","2"
    "","","Max: 7"

    Best Regards,
    Peter Stoev

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

    csv export and aggregates #28957

    rharding98
    Participant

    Guess I will have to setup an example to show you as it happens every time for me.

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

You must be logged in to reply to this topic.