This section covers Locking Group Columns which restricts users from ungrouping or rearranging group ordering.
By default, when no groupLockGroupColumns option is specified or if groupLockGroupColumns = 0 is specified, then no group column locking will be applied.
Locking Single Group Column
To lock group columns, provide the number of group columns to lock to the grid option groupLockGroupColumns. For example, to lock the first group column, you can specify groupLockGroupColumns = 1 as shown below:
const gridOptions = {
columnDefs: [
{ field: 'country', rowGroup: true, enableRowGroup: true, },
{ field: 'year', rowGroup: true, enableRowGroup: true },
{ field: 'sport', rowGroup: true, enableRowGroup: true },
{ field: 'gold' },
{ field: 'silver' },
{ field: 'bronze' },
],
// possible options: '-1', '0', '1', '2', '3', etc...
groupLockGroupColumns: 1,
// other grid options ...
}Note in the example above the following:
There are three active row groups as the supplied
country,yearandsportcolumn definitions haverowGroup=truedeclared.Group Column locking has only been applied to the first group column
country.Only
yearandsportcolumns can be rearranged or removed. Whilecountrycannot be rearranged or removed.The option to
Un-Group Allfrom the Group Column's context menu is displayed but clicking it doesn’t ungroup theCountrygroup as it's locked - it only ungroups any other groups.
Locking Multiple Group Columns
To lock multiple group columns, you can either specify the number of group columns to lock or you can provide the value groupLockGroupColumns = -1, which will lock all group columns.
For example, to lock the first two group columns, you can specify groupLockGroupColumns = 2:
const gridOptions = {
columnDefs: [
{ field: 'country', rowGroup: true, enableRowGroup: true, },
{ field: 'year', rowGroup: true, enableRowGroup: true },
{ field: 'sport', rowGroup: true, enableRowGroup: true },
{ field: 'gold' },
],
groupLockGroupColumns: 2,
groupDisplayType: 'multipleColumns',
// other grid options ...
}Note in the example above the following:
There are three active row groups as the supplied
country,yearandsportcolumn definitions haverowGroup=truedeclared.Group Column locking has been applied to the first two group column
countryandyear.As the example has
groupDisplayType='multipleColumns', it is possible toUn-Group by Sportvia the Sport Column's context menu. The column menus for theCountryandYearcolumns include theUn-group by CountryandUn-group by Yearmenu options, but as Country and Year columns are locked, these menu items are disabled.
Next Up
Continue to the next section to learn how to add Group Order.