subRowConfig
Optional. Specifies the configuration settings of a sub-row
Parameters
When the property is set as an object, the specified parameters are applied to all the rows.
When the property is set as a callback function, it is called with the row object as a parameter and returns the subRowConfig
object, which allows providing specific configuration for each particular row.
The subRowConfig
object may contain the following properties:
expanded
- (boolean) defines whether a sub-row is expanded by default, false by defaultpreserve
- (boolean) saves the state of sub-rows while expanding/collapsing, disappearing from the visible area, data updating, false by defaulttoggleIcon
- (boolean) enables the icon for expanding/collapsing, true by defaultheight
- (number) the height of a sub-row in pixels, controls the visibility of sub-rows, 200 by defaultpadding
- (string | number) the inner padding of a sub-row, 8 by defaultcss
- (string) user-defined CSS classes for a sub-rowfullWidth
- (boolean) defines whether a sub-row will take all the width of Grid, false by default
The fullWidth
property works only if the subRowConfig
property is initialized as an object.
Example
- the global configuration of sub-rows
const grid = new dhx.Grid("grid_container", {
columns: [
{ id: "zone_name", header: [{ text: "Zone name" }] },
{ id: "temperature", header: [{ text: "Temperature" }] },
],
data: dataset,
subRowConfig: {
height: 200,
padding: 8,
fullWidth: true,
},
subRow: ({ zone_name }) => `<div>Details for ${zone_name}</div>`,
});
- configuring sub-rows settings dynamically
The height
setting of the subRowConfig
property (set as a callback function) allows you to control the visibility of sub-rows. Set the height
setting to 0 if you don't want a sub-row to be created for particular rows.
const grid = new dhx.Grid("grid_container", {
columns:[
// columns config
],
data: dataset,
autoWidth: true,
subRowConfig: (row) => ({
height: row.data.length ? 250 : 0,
expanded: true
}),
subRow: (row) => new dhx.Grid(null, {
columns: [
// columns config
],
data: row.data
}),
});
Related sample:
Related article: Row expander
Related API: subRow