Our blazing fast Grid component built with pure JavaScript


Post by speedy059 »

In the Grid toolbar I have the pdfExport feature enabled. When they click the button, it calls the showExportDialog() function and shows the users all their options.

Is there a way where I can have it send the data to a custom function with the options they chose and the object/array of the selected columns/rows? We have so many columns that I can't use a standard PDF solution, it keeps getting cut off. So I need to send the data to the server where I'll generate my own PDF with the data.

Thanks


Post by alex.l »

Try to listen preventable https://bryntum.com/docs/grid/api/Grid/feature/export/PdfExport#event-beforeExport that has all export configs.

But could you please describe the problem with "cut off" of your columns? Can we reproduce it somehow?

All the best,
Alex


Post by speedy059 »

alex.l wrote: Tue Jan 11, 2022 8:32 am

Try to listen preventable https://bryntum.com/docs/grid/api/Grid/feature/export/PdfExport#event-beforeExport that has all export configs.

But could you please describe the problem with "cut off" of your columns? Can we reproduce it somehow?

I have a table with 65-70 columns. It can't fit on a landscape page with the current CSS for the table. I also didn't like trying to setup the pdf export solution you had since the packages it required are so outdated. Instead I'm using https://gotenberg.dev/ which has a nice little docker image. There are also various client packages made for it, which were easy to implement (Javascript or PHP clients).

I also tried using beforeExport and I'm not sure where the row data is? It's a pretty big object that is sent, I imagine the rows are buried somewhere in there.


Post by alex.l »

Sure, here it is

grid.on('beforeExport', ({ config }) => {
	const { columns, rowsRange } = config;
	// ...
})

There is no information with rows, it is a job of our Exporter who collect these data. But actually, if you selected rowsRange == 'visible', you can use
https://bryntum.com/docs/grid/api/Grid/row/RowManager#property-firstVisibleRow
https://bryntum.com/docs/grid/api/Grid/row/RowManager#property-lastVisibleRow
https://bryntum.com/docs/grid/api/Grid/row/RowManager#property-rows

firstVisibleIndex = rowManager.rows.indexOf(rowManager.firstVisibleRow);
lastVisibleIndex  = rowManager.rows.indexOf(rowManager.lastVisibleRow);

and use these indices to get required records from the store and collect them.
https://bryntum.com/docs/grid/api/Core/data/Store#function-getRange

In case rowsRange == 'all', just get all records from the store.

All the best,
Alex


Post Reply