shlomiassaf/ngrid

How to manually toggle a detailrow on/off?

ahmed-habbachi opened this issue · 1 comments

Please describe the feature you would like to request.

Manually / programmatically toggle a detailrow on/off

What is the use-case or motivation for this proposal?

I have a situation where i want to add a new record to the grid and I want to use the detailRow to fulfill the details.
so my intention was to create an empty row via an external button and show the detail row to fulfill the details and then save the changes,
the details contains more fields than the grid shows for the object.

Is there anything else we should know?

@ahmed-habbachi You need to get the instance of the detailRow plugin and then provide the row you want to toggle on/off.

To get the plugin instance:

const detailRowPlugin = PblNgridPluginController.findPlugin(gridInstance, 'detailRow');

And then, just toggle it:

detailRowPlugin.toggleDetailRow(row);

Where row is the data row to toggle (the actual data object)

Note that this only works for rendered rows, i.e. if virtual scroll is enabled only the visible rows can get toggled.

See a working example here:

https://codesandbox.io/s/ngrid-detail-row-programmatic-toggle-r2fcf?file=/src/app/app.component.ts:2150-2236