Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
515
Regarding Excel file download
posted

Hello ,

So , i tried to export files only those which are checked.Now , i want to do like when i click export it download all the content and when i select rows and click export it will download them. How can we do that?

Heres my code :

$("#b2").on("click",function(){
$.ig.GridExcelExporter.exportGrid(
$('#grid'),
{
fileName: 'igGrid',
worksheetName: 'Sheet1'
},
{
rowExporting: function (sender, args) {
var id = args.rowId;
var selectedRows = $("#grid").igGridSelection("selectedRows");
for (var i = 0; i < selectedRows.length; i++) {
if (selectedRows[i].id === id) {
return true;
}
}
return false;
}


}

);

  • 460
    Offline posted

    Hello,

    I have been looking into your question and what I can offer you as an approach regarding your requirements is, in the previous logic, to export only selected rows with GridExcelExporter, when handling the rowExporting event, you take the selected rows with the selectedRows method, loop through them and export only them.

    In this line of thought, when you have no selected rows, that is, you are exporting the entire grid, you can add an additional check if you have selected rows and if you are not going to return true, that is, export the row, and so you will export every single row of the grid, or in other words, the entire grid.

    var selectedRows = $("#grid").igGridSelection("selectedRows");
        if(selectedRows.length === 0){
          return true;
        }

    Here the return of true means you will want to export the row and continue with the next one, and as soon as there are no selected rows, that is, true will be returned for each row, that is, it will be exported.

    The described scenario could be observed here:

     

    In addition, I have prepared small sample illustrating this behavior which could be found here. Please test it on your side and let me know how it behaves.

    If you require any further assistance on the matter, please let me know.

    Regards,

    Georgi Anastasov

    Entry Level Software Developer

    Infragistics