You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: controls/grid/defining-structure/creating-a-radgrid-programmatically.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,9 @@ This help article describes two options for creating a **RadGrid** instance dyna
18
18
19
19
* You can create the **RadGrid** entirely in the code-behind.
20
20
21
+
>Note
22
+
This article demonstrates how to create and configure the RadGrid control programmatically on the code-behind, given that the data source structure will remain the same. If you want to dynamically change the columns of the grid depending on user selection or some dynamic condition (remove or add columns with different DataFields than the initial loaded structure), this might mess up the ViewState. For this scenario, please refer to the next [Changing the Grid Structure Dynamically on Postback]({%grid/defining-structure/changing-the-grid-structure-dynamically-on-postback%}) article.
23
+
21
24
When defining the structure of a hierarchical grid (by either method), you should follow these rules:
22
25
23
26
1. Create the **GridTableView** objects for every detail table. You do not need to create an object for the **MasterTableView** of the grid, as this is created automatically when the **RadGrid** itself is created.
@@ -55,19 +58,19 @@ To define the structure of a **RadGrid** control that is declared in the ASPX pa
Copy file name to clipboardExpand all lines: controls/grid/hierarchical-grid-types-and-load-modes/what-you-should-know.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,15 @@ The new expand-all functionality supports all hierarchy load modes.
38
38
39
39
When you have grouping and hierarchy combined in a common table view, the visibility of the hierarchy expand-all button depends on whether the expand-all button for the last group level is expanded/visible.
40
40
41
+
## Controlling Expanded State
42
+
43
+
By default, the items in a hierarchical RadGrid are collapsed. In order to expand them automatically, you can use the **HierarchyDefaultExpanded** property. If the hierarchy structure contains several levels, the property should be set for every GridTableView instance separately.
44
+
````ASP.NET
45
+
<MasterTableView HierarchyDefaultExpanded="true">
46
+
````
47
+
48
+
Since Q3 2013 version, RadGrid also provides the convenient **RetainExpandStateOnRebind** property. When you enable it, the expanded state of the parent items will be preserved automatically on rebinding actions like Paging, Editing, etc.
49
+
41
50
## See Also
42
51
43
52
*[Hierarchical data-binding using declarative relations]({%slug grid/hierarchical-grid-types-and-load-modes/hierarchical-data-binding-using-declarative-relations%})
0 commit comments