Demonstrates, with code examples, how to configure the igHierarchicalGrid™ control’s Row Selection feature.
The following lists includes the topics required as a prerequisite to understanding this topic.
This topic contains the following sections:
Here are the configurable aspects of the row selection feature. These aspects are managed through the respective properties of the igGridRowSelectors widget. Detailed explanations and examples of some of the behaviors and features of the widget follow the table.
Configurable aspects | Details | Properties |
---|---|---|
Selection of multiple rows | By default multiple row selection is enabled. This is controlled through the igGridSelection control. | multipleSelection (igGridSelection™) |
Selection with checkboxes | Enables checkboxes in the Row Selectors column. | enableCheckBoxes |
Row numbering | When enabled, allows row numbering of the Row Selectors column. | enableRowNumbering |
Row numbering starting value | Allows Row numbering to start from a custom value. | rowNumberingSeed |
Width of the row selectors column | Sets the width of the row selector column. | rowSelectorColumnWidth |
Require a Selection to configure | Causes the control to throw an exception if the Selection feature is disabled. | requireSelection |
Note:Keep in mind that
RowSelectors
behavior is per layout. Only one layout can have selection at a time, so if you select/check a row in a different layout, the selected rows from the previous layout will become unselected. For more information see the Known Issues and Limitations (igHierarchicalGrid) topic.
Initializing the Selection feature for the grid enables cell or row selection using the igHierarchicalGrid control’s Row Selection feature. This does not automatically initialize the selection feature you must enable it if you need it. The Row Selection can still be used without the selection feature, for example for row numbering.
In the picture below, Row Selection and Selection features are enabled. A red rectangle designates the Row Selectors column.
In JavaScript:
$(function () {
$("#grid").igHierarchicalGrid({
initialDataBindDepth: 1,
dataSource: data,
dataSourceType: "json",
responseDataKey: "Records",
autoGenerateColumns: true,
autoGenerateLayouts: true,
primaryKey: "ID",
features: [
{
name: "RowSelectors",
inherit: true
},
{
name: "Selection",
multipleSelection: true,
mode: "row"
}
]
});
});
In ASPX:
<%= Html.Infragistics()
.Grid(Model)
.ID("grid")
.Features(features =>
{
features.RowSelectors().Inherit(true);
features.Selection().Mode(SelectionMode.Row).MultipleSelection(true);
features.Paging().Type(OpType.Local).PageSize(5);
})
.AutoGenerateColumns(true)
.AutoGenerateLayouts(true)
.DataBind()
.Render()
%>
Checkboxes are added by setting the igGridRowSelectors control’s enableCheckBoxes
property to true. It is recommended that you use multiple-selection if checkboxes are enabled. This will allow the user to select multiple rows without holding down the Ctrl key. When Row Selectors checkboxes are enabled the multiple-selection behavior persists across pages.
The picture below shows a hierarchical grid with row selectors checkboxes enabled. The red ellipse emphasis the checkboxes on the first two master rows.
In HTML:
<script type="text/javascript">
$(function () {
$("#grid").igHierarchicalGrid({
initialDataBindDepth: 1,
dataSource: data,
dataSourceType: "json",
responseDataKey: "Records",
autoGenerateColumns: true,
autoGenerateLayouts: true,
primaryKey: "ID",
features: [
{
name: "RowSelectors",
enableCheckBoxes: true
inherit: true
},
{
name: "Selection",
multipleSelection: true,
mode: "row"
},
{
name: "Paging",
type: "local"
}
]
});
});
</script>
In ASPX:
<%= Html.Infragistics()
.Grid(Model)
.ID("grid")
.Features(features =>
{
features.RowSelectors().EnableCheckBoxes(true).Inherit(true);
features.Selection().Mode(SelectionMode.Row).MultipleSelection(true);
features.Paging().Type(OpType.Local);
})
.AutoGenerateColumns(true)
.AutoGenerateLayouts(true)
.DataBind()
.Render()
%>
You can also render sequential row numbering for all rows in the row selector column in a grid. This is managed through the rowNumbering
option of the igGridRowSelectors
widget.
The following screenshot illustrates the rendering of a grid with row selectors enabled:
In HTML:
<script type="text/javascript">
$(function () {
$("#grid").igHierarchicalGrid({
initialDataBindDepth: 1,
dataSource: data,
dataSourceType: "json",
responseDataKey: "Records",
autoGenerateColumns: true,
autoGenerateLayouts: true,
primaryKey: "ID",
features: [
{
name: "RowSelectors",
enableRowNumbering: true
inherit: true
},
{
name: "Selection",
multipleSelection: true,
mode: "row"
}
]
});
});
</script>
In ASPX:
<%= Html.Infragistics()
.Grid(Model)
.ID("grid")
.Features(features =>
{
features.RowSelectors().EnableRowNumbering(true).Inherit(true);
features.Selection().Mode(SelectionMode.Row).MultipleSelection(true);
features.Paging().Type(OpType.Local);
})
.AutoGenerateColumns(true)
.AutoGenerateLayouts(true)
.DataBind()
.Render()
%>
The first number for sequential row numbering can be manually configured by assigning a seed value. This is managed through the rowNumberingSeed
option of the igGridRowSelectors
widget.
The screenshot below demonstrates how a grid with offset row numbering looks:
In HTML:
<script type="text/javascript">
$(function () {
$("#grid").igHierarchicalGrid({
initialDataBindDepth: 1,
dataSource: data,
dataSourceType: "json",
responseDataKey: "Records",
autoGenerateColumns: true,
autoGenerateLayouts: true,
primaryKey: "ID",
features: [
{
name: "RowSelectors",
enableRowNumbering: true,
rowNumberingSeed: 9,
inherit: true
},
{
name: "Selection",
multipleSelection: true,
mode: "row"
}
]
});
});
</script>
In ASPX:
<%= Html.Infragistics()
.Grid(Model)
.ID("grid")
.Features(features =>
{
features.RowSelectors().Inherit(true)
.EnableRowNumbering(true).RowNumberingSeed(9);
features.Selection().Mode(SelectionMode.Row)
.MultipleSelection(true);
features.Paging().Type(OpType.Local);
})
.AutoGenerateColumns(true)
.AutoGenerateLayouts(true)
.DataBind()
.Render()
%>
Configure the row selector column’s width of through the igGridRowSelectors widget’s rowSelectorColumnWidth
option. The width can be set in pixels (75px
) as well as in percent (10%
). If no value is set then the widget automatically sets the width is to an appropriate value.
The following screenshot below illustrates the rendering of a grid’s row selector column with its width set to 75 pixels. The enlarged width is emphasized with the red arrow and line.
In HTML:
<script type="text/javascript">
$(function () {
$("#grid").igHierarchicalGrid({
initialDataBindDepth: 1,
dataSource: data,
dataSourceType: "json",
responseDataKey: "Records",
autoGenerateColumns: true,
autoGenerateLayouts: true,
primaryKey: "ID",
features: [
{
name: "RowSelectors",
enableRowNumbering: true,
rowSelectorColumnWidth: "75px",
inherit: true
},
{
name: "Selection",
multipleSelection: true,
mode: "row"
}
]
});
});
</script>
In ASPX:
<%= Html.Infragistics()
.Grid(Model)
.ID("grid")
.Features(features =>
{
features.RowSelectors().Inherit(true)
.EnableRowNumbering(true).RowSelectorsColumnWidth("75px");
features.Selection().Mode(SelectionMode.Row).MultipleSelection(true);
features.Paging().Type(OpType.Local);
})
.AutoGenerateColumns(true)
.AutoGenerateLayouts(true)
.DataBind()
.Render()
%>
The following topics provide additional information related to this topic.
The following samples provide additional information related to this topic.
RowSelectors
in igHierarchicalGrid.View on GitHub