Our blazing fast Grid component built with pure JavaScript


Post by tjmeal »

I have the following excel button >

The problem i would like to solve is > grid.columns.visibleColumns > it give me also the columns with exportable: false.

How can i get all the visible column that are allowed to be exported ?

      {
        type: "button",
        text: 'Export Excel',
        icon: 'b-fa b-fa-file-excel',
        onClick() {
          const grid = gridRef.current.instance;
          const columns = [...grid.columns.visibleColumns, "intermediateStops"]

      gridRef.current.instance.features.excelExporter.export({
        exporterConfig: {
          rows: getSelectedRecordOrAllGrid(grid),
          columns: columns
        }
      })
    },
  },

Post by marcio »

Hey tjmeal,

Thanks for reaching out.

To filter out columns that are not exportable, you can use the exportable property of the column configuration. You can modify your code to filter the visibleColumns array like this:

const grid = gridRef.current.instance;
const columns = grid.columns.visibleColumns.filter(column => column.exportable !== false);
columns.push("intermediateStops");

gridRef.current.instance.features.excelExporter.export({
  exporterConfig: {
    rows: getSelectedRecordOrAllGrid(grid),
    columns: columns
  }
});

This will ensure that only columns marked as exportable are included in the export.

Best regards,
Márcio

How to ask for help? Please read our Support Policy


Post by tjmeal »

Thank you very much.


Post Reply