Replies
int currentIndexPage = ((WebHierarchicalDataGrid)sender).Behaviors.Paging.PageIndex;
This line does not work. It throws an error saying –
Cannot cast 'sender' (which has an actual type of 'Infragistics.Web.UI.GridControls.ContainerGrid') to 'Infragistics.Web.UI.GridControls.WebHierarchicalDataGrid' Infragistics.Web.UI.GridControls.WebHierarchicalDataGrid
I have replaced the line with –
int currentIndexPage = ((ContainerGrid)sender).Behaviors.Paging.PageIndex;
Hi Lyuba,
Here is the markup for the WebHierarchichalDataGrid –
<ig:WebHierarchicalDataGrid ID="ProjectWebHierarchicalDataGrid" runat="server" Height="350px" Width="100%" DataMember="ProductFamily" DataKeyFields="PRODUCT_FAMILY_ID" AutoGenerateBands="false" AutoGenerateColumns="false" InitialDataBindDepth="1" InitialExpandDepth="1">
<Columns>
<ig:BoundDataField DataFieldName="PRODUCT_FAMILY_DESCRIPTION" Key="PRODUCT_FAMILY_DESCRIPTION" Header-Text="Product Family" />
</Columns>
<Bands>
<ig:Band DataMember="Project" DataKeyFields="PROJECT_ID" AutoGenerateColumns="false">
<Columns>
<ig:BoundDataField DataFieldName="ARCHITECTURE_YEAR" Key="ARCHITECTURE_YEAR" Header-Text="Year" />
<ig:BoundDataField DataFieldName="PROJECT_NAME" Key="PROJECT_NAME" Header-Text="Project Name" />
<ig:BoundDataField DataFieldName="PROJECT_STATUS_DESCRIPTION" Key="PROJECT_STATUS_DESCRIPTION" Header-Text="Status" />
</Columns>
<Behaviors>
<ig:Sorting />
</Behaviors>
</ig:Band>
</Bands>
<Behaviors>
<ig:Sorting />
</Behaviors>
</ig:WebHierarchicalDataGrid>
I created a dataset with 2 data tables and the data tables are related with the PRODUCT_FAMILY_ID column. I could see 2 rows in the parent table and 1 row each for the parent in the child table. The hierarchical grid does not expand the 2nd level. Whereas if I don't create the bands and columns and set the AutoGenerateBands and AutoGenerateColumns to true, it shows the 2nd level expanded. Please advise!
Hi Lyuba,
How do I enable the initial expand depth when the AutoGenerateBands and AutoGenerateColumns are both false? I need to display 2 levels of hierarchical data expanded. It is working when the bands are not defined.
I tried setting InitialDataBindDepth, InitialExpandDepth and MaxDataBindDepth both in design and run-time, but no luck.
WebHierarchicalDataGrid1.InitialDataBindDepth = 1; //2
WebHierarchicalDataGrid1.InitialExpandDepth = 1; //2
WebHierarchicalDataGrid1.MaxDataBindDepth = 2; //2
I would appreciate your kind help!
Thanks
Hey Lyuba,
I am getting the error "Runtime Exception: [object Error]" on adding the code to enable sorting at child band level.
childGrid.Behaviors.CreateBehavior<Sorting>();
childGrid.Behaviors.Sorting.Enabled = true;
SortingColumnSetting scs2 = new SortingColumnSetting();
scs2.ColumnKey = "ProductName";
scs2.Sortable = false;
childGrid.Behaviors.Sorting.ColumnSettings.Add(scs2);
Thank you Lyuba for providing the sample.
I was able to dynamically add data bound fields to the childGrid and change the header text.
childGrid.AutoGenerateColumns = false;
BoundDataField bdf1 = new BoundDataField(true);
bdf1.DataFieldName = "ProductID";
bdf1.Header.Text = "Product ID";
bdf1.Key = "ProductID";
childGrid.Columns.Add(bdf1);
BoundDataField bdf2 = new BoundDataField(true);
bdf2.DataFieldName = "ProductName";
bdf2.Header.Text = "Product Name";
bdf2.Key = "ProductName";
childGrid.Columns.Add(bdf2);
However, I am unable to set the columns as sortable. Could you please provide a sample code for the same?
SortingColumnSetting scs1 = new SortingColumnSetting();
scs1.ColumnKey = "ProductID";
scs1.Sortable = true;
childGrid.Behaviors.Sorting.ColumnSettings.Add(scs1);
This doesn't work.
Hey Lyuba,
I see a problem. The arrow for the user to expand at the parent level is visible only when I bind the child level data. That means, I have to bind all the 4 levels in order to override the RowIslandsPopulating event.
How can I display the arrow at the parent level by not binding the child levels so that I can manually perform load on demand for the childrens?
I would appreciate your response!
Thanks