Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Grouping order not maintained during CSV export

    Tested in SmartClient_v101p_2016-11-04_PowerEdition, Chrome 54

    We utilize the CSV export functionality in the grid. Users have noticed that the display order of records is not maintained during an export to CSV after grouping.

    Is the expected behavior that grouping has no impact on order when data is exported?

    REPRO Steps
    =============
    1. Load test case.
    2. Note the order of the Record Number column.
    3. Group by Country/Region.
    4. Note the order of the Record Number column.
    5. Press the Export Client CSV button.
    6. Open the CSV file and note the order of the Record Number column.
    7. Observe that the order of the CSV file and the order of the displayed grid are different.

    Code:
    <!DOCTYPE html>
    
    <html>
        <head>
    
            <title></title>
            
            <style>
                .diagInfo {
                    font-size: 14px;
                    font-weight: bold;
                    padding: 5px;
                }
            </style>
            
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Core.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Foundation.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Containers.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Grids.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Forms.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_DataBinding.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Drawing.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_PluginBridges.js"></script> 
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Charts.js"></script>    
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
         
            <script type="text/javascript" >
                var isomorphicDir="http://localhost:8080/isomorphic/";
                
                // set this to the correct JIRA ticket
                var JIRA_TICKET = "PSS-538";
                
                var data = [
                    {recordNumber:1, region:"North", accountHolder:"Alice" },
                    {recordNumber:2, region:"West", accountHolder:"Alice" },
                    {recordNumber:3, region:"East", accountHolder:"Alice" },
                    {recordNumber:4, region:"South", accountHolder:"Alice" },
                    {recordNumber:5, region:"North", accountHolder:"Alice" },
                    {recordNumber:6, region:"West", accountHolder:"Alice" },
                    {recordNumber:7, region:"East", accountHolder:"Bob" },
                    {recordNumber:8, region:"South", accountHolder:"Bob" },
                    {recordNumber:9, region:"North", accountHolder:"Bob" },
                    {recordNumber:10, region:"West", accountHolder:"Bob" },
                    {recordNumber:11, region:"East", accountHolder:"Bob" },
                    {recordNumber:12, region:"South", accountHolder:"Bob" }
                ];
                // datasource for the grid        
                isc.DataSource.create({
                    ID: "ds",
                    cacheData:data,
                    clientOnly: true
                });
                
                // once page loads set some diagnostic information, DO NOT CHANGE
                isc.Page.setEvent("load", function() {
                    document.title = JIRA_TICKET + "   (SmartClient version " + isc.versionNumber + ")";
                    var html = [];
                    html.push("Jira: " + JIRA_TICKET);
                    html.push("SmartClient: " + isc.versionNumber);
                    html.push("Browser: " + navigator.appCodeName + " " + navigator.appName + " " + navigator.appVersion);
                    diagLabel.setContents( html.join("<br>"));
                });
                
    
            </script>
    
        <!--mstheme--><link rel="stylesheet" type="text/css" id="onetidThemeCSS" href="../../_themes/Lichen/Lich1011-65001.css"><meta name="Microsoft Theme" content="Lichen 1011, default">
    </head>
        
        <body>
            <script>
            
                // ===== DO NOT REMOVE =====
                var diagLabel = isc.Label.create({
                            ID: "diagInfo",
                            width: "100%",
                            styleName: "diagInfo",
                            autoFit: true
                        });
                // ===== DO NOT REMOVE =====
                            
                // basic grid        
                var grid = isc.ListGrid.create({
                    dataSource: ds,
                    
                    fields: [
                        {name:"recordNumber", type:"integer", title:"Record Number"},
                        {name:"region", type:"text", title:"Region/Country"},
                        {name:"accountHolder", type:"text", title:"Account Holder"}
                    ],
                    autoFetchData: true,
                    dataFetchMode : "local",            position: "relative",
                    width : "100%",
                    align : "center",
                    autoFitData : "vertical",
                    autoFitMaxHeight : 400,
                    alternateRecordStyles : true,
                    canAddFormulaFields : true,
                    canAddSummaryFields : true,
                    canGroupBy : true,
                    canReorderFields : true,
                    showGroupSummary : true,
                    groupByMaxRecords : 20,
                    useAdvancedFieldPicker: true,
                    advancedFieldPickerThreshold: 5,
                    autoDraw: false
                });    
                
                    
                // the main page layout - place all other components afetr diagLabel
                var layout = isc.VLayout.create({
                    width:"100%",
                    membersMargin: 20,
                    members: [
                        // ===== DO NOT REMOVE diagLabel
                        diagLabel,
                        grid,
                        isc.IButton.create({
                            title : "Export Client CSV",
                            click : function() {
                                exportOpts = {
                                    exportAs : "csv",
                                    exportDisplay : "download",
                                    exportFilename : JIRA_TICKET + "-exportData.csv"
                                    
                                };
                                grid.exportClientData(exportOpts);
                            }
                        }) 
                                
                    ]
                });
        
                    
            </script>
    
        </body>
    
    </html>

    #2
    Correct, we do not try to reproduce grouping in CSV export, as there is no reasonable way to output the group headers, summary information and other details in an export that has fixed columns.

    If you just want to replicate the sort order that is produced by grouping, you could just sort.

    If you wanted to reproduce the group headers in some by fudging common columns between group headers and normal records, you could put together data like that by traversing the groupTree, and then export that.

    Comment


      #3
      The expectation is not that export includes group headers, rather, that the exported data maintains the same order as the displayed data.
      Unfortunately, sorting after grouping does not maintain the sort order either.

      REPRO Steps (Using the same sample code)
      =============
      1. Load test case.
      2. Note the order of the Record Number column.
      3. Group by Country/Region.
      4. Sort by Country/Region DESC.
      5. Note the order of the Record Number column.
      6. Press the Export Client CSV button.
      7. Open the CSV file and note the order of the Record Number column.
      8. Observe that the order of the CSV file and the order of the displayed grid are different.

      Comment


        #4
        Right, no aspect of the grouped display is replicated in the export (since the grouping itself cannot be replicated, we don't try to replicate subsets of it either). So our previous suggestion was to sort without grouping if you want sorted output.

        Comment

        Working...
        X