WebGrid.NET with Self Reference has a setting called ParentRootMode. ParentRootMode is a property as a pointer where the root of the self referencing table is.
ParentRootMode contains 3 options :
- UseParentRootValue : UseParentrootValue is a property to show self reference table based on the parent value.
- NullValue : NullValue is a property to show self reference table based on null value.
- SelfReferencingNode : SelfReferencingNode is a property to show the selfreference table based on only the parentnode which has reference.
In order to use ParentRootMode based on the UseParentRootValue, we need to define some major SelfReference settings. Please check sample code belows:
C# | Copy Code |
WebGrid1.RootTable.SelfReferencingSettings.Enabled = true; WebGrid1.RootTable.SelfReferencingSettings.ParentDataMember = "EmployeeID"; WebGrid1.RootTable.SelfReferencingSettings.ChildDataMember = "ReportsTo"; WebGrid1.RootTable.SelfReferencingSettings.ExpandColumnMember = "FirstName"; WebGrid1.RootTable.SelfReferencingSettings.ParentRootMode = ISNet.WebUI.WebGrid.ParentRootMode.UseParentRootValue; // A DropDownList is configured with a collection of the possible values of ParentRootValue WebGrid1.RootTable.SelfReferencingSettings.ParentRootValue = Int32.Parse(DropDownList1.SelectedItem.Value); |
Above codes is recommended to be placed inside PrepareDataBinding event if Runtime Data Binding method is utilized, but if DesignTime Data Binding method is utilized, then it's safe to place above codes inside InitializeLayout or PrepareDataBinding event since the columns collection have been determined earlier using DesignTime Data Binding.
There are 4 major properties which need to be placed in order to configure Self Referencing table. They are : Enabled, ParentDataMember, ChildDataMember and ExpandColumnMember. Since we would like to designate a value other than 'Null' value as the ParentRootValue then the ParentRootMode property as well as ParentRootValue property need to be configured.
Overview
Getting Started
WebGrid Features Overview
Other Resources
Walkthrough Topics
How-to Topics