Author Topic: Export Excel with remote data and virtual scrolling  (Read 2298 times)

flipo

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Export Excel with remote data and virtual scrolling
« on: January 18, 2018, 02:33:42 pm »
In Excel only the rows loaded into the grid are visible and not the complete data (all the rows) with virtual scrolling. How can I export the complete data and not only the rows loaded into the grid?
I found a way, but it's not what I want: First I click on the reload button to load 1000000 rows at once.
When I click onto the Excel Export all the rows are displayed.

So I try to the same method without clicking the Reload button before Excel Export, but that doesn't work.
Only the loaded rows are also displayed in the Excel, because the Export starts immediately before the grid was reloaded.

Is there a way to add an event to refreshDataAndView so that the Excel Export can only start after the refresh.
Or is there a better method for Excel Export with remote data and virtual scrolling?

Here is the actual code:

var obj = {
  toolbar: {
            cls: 'pq-toolbar-export',
            items: [{
                type: 'button',
                label: 'Reload',
                icon: 'ui-icon-arrowrefresh-1-e',
                listeners: [{
                    "click": function (evt) {     
                        pqVS.rpp=1000000;     
                        $grid.pqGrid('refreshDataAndView');
                        }
                    }]
                },
                {
                type: 'button',
                label: 'Excel Export',
                icon: 'ui-icon-document',
                listeners: [{
                    "click": function (evt) {
                        pqVS.rpp=1000000;
                        $grid.pqGrid('refreshDataAndView');
                        $("#grid_php").pqGrid("exportExcel", { url: "export_xls.php", sheetName: "pqGrid sheet", filename: "TEST" });
                        }
                    }]
                }
                ]
            }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Export Excel with remote data and virtual scrolling
« Reply #1 on: January 18, 2018, 04:52:50 pm »
It's necessary that all the remote data is available before export can take place.

There is load event whenever remote data is loaded.

Code: [Select]
listener: function(){
  pqVS.rpp=1000000;
  this.refreshDataAndView();
  this.one('load', function(){
     //call the export method here.
     this.exportExcel(........);
  });
}

flipo

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Export Excel with remote data and virtual scrolling
« Reply #2 on: January 18, 2018, 06:06:17 pm »
Thanks, works fine!