4. Default rows and columns
Predefined values for more rows and columns
Default rows
- See Default rows documentation.
-
Default row predefines all row attributes that the row does not explicitly set. Setting attribute to empty string overrides the default value.
For example if set <D Name='XXX' A='DefA' B='DefB'/> and <I Def='XXX' A='RA' C='RC'/>, the row will have these three attributes A='RA' B='DefB' C='RC'
-
Every row in grid has set always one default row. The default row is set by the row attribute
Def
. Unlike columns and defaults, the row Def attribute can contain only one item!
If the row has not set Def attribute, its value is read from parent row CDef
attribute. The CDef attribute is used also to set Def for all new children added to the parent.
Default CDef value for root variable rows can be set by root <Root CDef="..."/> tag.
-
If row has set neither Def nor its parent CDef, its default row is set to "R" for variable rows, "Header" for header rows, "Fixed" for other fixed rows and "Solid" for solid rows.
The "R", "Header", "Fixed" and "Solid" defaults are defined in Grid/Defaults.xml, but is possible to change them in any your XML.
There is also one predefined default row "Group" that is used by default for all rows created by grouping, see 03-Grouping_rows tutorial.
And one default row "CPage" used for child rows created by MaxChildren settings, see Paging in tree - MaxChildren documentation.
Note that Fixed and Group default rows inherit the "R" default row too (have Def='R'), but the Header, Solid and CPage default rows don't inherit anything (have Def='').
-
The default rows are defined by
<D/>
tag in root <Def> ... </Def>
tag.
Every default row <D> must have set its attribute Name
to identify the default row. This value is used in row's Def and CDef attributes to link this default row.
Default row can also define its Def attribute to inherit it from one or more other default rows. More items are comma separated. Default value for Def attribute is "R", so by default all default rows inherit default row named "R".
-
The <D> tag can have also child <I> tags. When added new row of this default row, it will automatically get new created children as these defined <I> tags.
It is possible to have only one level of such <I> children of default row. But the child <I> tags can have set their Def attribute and if this default has also child rows, they are added too. In such way you can create many levels of children for one new row.
-
Default row is used also for permissions when moving row to new parent. The row is accepted only if its Def attribute value is listed in the new parent row AcceptDef attribute.
For more information see 01-Dragging_rows tutorial.
-
By
API
you can access the default row by Grid.Def[name]. It is possible to directly read and write the default row attributes like Grid.Def["R"].Color = "Red";
The inheritance between two default rows (by the <D Def/>) is resolved on grid start, so changing one default row attribute by API will not affect any other default row.
Read the row attribute including the default value by global Get method or by grid methods GetAttribute or GetValue.
You can get the row's default row object by row.Def and its name by row.Def.Name.
Default columns
- See Column basics documentation.
-
Default column predefines all column attributes that the column does not explicitly set. Setting attribute to empty string overrides the default value.
For example if set <D Name='XXX' Color='Red' Class='Blue'/> and <C Def='XXX' Class='Green' CanEdit='0'/>, the column will have these three attributes Color='Green' Class='Blue' CanEdit='0'
-
Every column in grid has set one or more default columns. The default columns are set by the column attribute
Def
. More items are comma separated.
If column has not set the Def attribute, its default column is "C", only for Gantt type column it is "Gantt". The "Gantt" default column inherits also the "C" column.
The "C" and "Gantt" default columns are defined in Grid/Defaults.xml, but is possible to change them in any your XML.
-
The default columns are defined by
<D/>
tag in root <DefCols> ... </DefCols>
tag.
Every default column <D> must have set its attribute Name
to identify the default column. This value is used in column's Def attribute to link this default column.
Default column can also define its Def attribute to inherit it from one ore more other default column. More items are comma separated. Default value for Def attribute is "C", so by default all default columns inherit default column named "C".
-
By
API
you cannot access the default columns (unlike default rows). The default columns are processed on grid start, all columns read their not set attributes from default columns on start.
To access column attribute use GetAttribute API method or directly by Grid.Cols[name].
-
Note, Header rows don't read their cell attributes from columns, only from the header row or its default row.