javascriptruby-on-railscoffeescriptag-gridag-grid-validation

AG-GRID Excel Export: Is there any way in AG-Grid to configure Records Export Limit per user?


Is there any way to to restrict Excel Export limit from AG-Grid, so that only allowed number of rows can be exported by a User.

For an Example, if Grid is showing 75,000 Records, can we limit Excel to export only 10,000 (or any configurable number) records ?


Solution

  • Not per configuration, no. But you can implement this functionality yourself as one of the exportparams for

    gridOptions.api.exportDataAsExcel(exportParams);
    

    is a callback function shouldRowBeSkipped.

    So a possible implementation would look something like this (not tested):

    var exportedRows = 0;
    
    var exportParams = {
      shouldRowBeSkipped: function(params) {
        exportedRows++;
        return exportedRows <= 10000;
      }
    };
    
    gridOptions.api.exportDataAsExcel(exportParams);
    

    Have a look at all the export params: https://www.ag-grid.com/javascript-grid-export/