We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Grid with virtualization get filtered Data

Hello,

I am currently working with javascript (ES5 v.17.1.49) and I have a Grid with  "enableVirtualization" set to true.
When I filter the data and try to export it I only have access to :
  • dataSource
  • getSelectedRowIndexes()
  • currentViewData
But the currentViewData has only what is display on screen and not the whole data filtered (ex: 70 records before filter, 55 after filter, and 42 inside the currentViewData);

How can I get the list of filteredData record so I can export/work with it?


Thank you,

3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team July 17, 2019 11:47 AM UTC

Hi Bernard, 

Thanks for contacting Syncfusion support. 

By default, Grid will export the given dataSource even after filtering several columns or doing anyother actions. But in the toolbarClick event, we can generate a query and execute them on the Grid dataSource. Later, the result will be given to the pdfExport method as the Export Properties. Refer to the following code example.  

<script> 
 
    var grid = new ej.grids.Grid({ 
        dataSource: orderData, 
        allowFiltering: true, 
        allowPdfExport: true, 
        filterSettings: { type: 'Excel' }, 
        toolbar: ['PdfExport'], 
        toolbarClick: function (args) { 
            if (args.item.text === 'PDF Export') { 
                let query = grid.renderModule.data.generateQuery(true); // get grid corresponding query 
                grid.getDataModule().executeQuery(query).then((e) => { 
                    console.log(e.result); 
                    grid.pdfExport({ dataSource: e.result });  //Export the filtered data. 
                }).catch((e) => { 
                    console.log(e); 
                }) 
            } 
        }, 
        enableVirtualization: true, 
        height: 400, 
         . . .  
            . . . 
    }); 
    grid.appendTo('#Grid'); 
 
</script> 



Note: If Grid in filtered state only you will get the filtered data while export. Otherwise you will get the entire dataSource in the result. 

Please get back to us, if you need further assistance. 

Regards, 
Seeni Sakthi Kumar S. 



BL BERNARD Ludovic July 18, 2019 08:53 AM UTC

Thank you I works that way.


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team July 18, 2019 10:49 AM UTC

Hi Bernard, 

Thanks for the update.  

We are happy to hear that your requirement has been resolved. Please get back to us, if you require further assistance on this.  

Regards,  
Seeni Sakthi Kumar S. 


Loader.
Live Chat Icon For mobile
Up arrow icon