Hi,
I have an issue with hiding columns in Band(1).
In Band(0), hiding a column can be done by:WebHierarchicalDataGrid1.GridView.Columns(0).Hidden = True
So I tried for Band(1):WebHierarchicalDataGrid1.GridView.Band.Bands(1).Columns(0).Hidden = True
But that doesn't work.
Thanks,Andreas
Hi Andreas,
WebHierarchicalDataGrid1.GridView.Band.Bands(1) should be equivalent to
WebHierarchicalDataGrid1.Bands(1) since the Band of the GridView is the Hiearchical grid itself. But anyway. What event are you trying to call this code? By attempting to set the column hidden on the band, you want the column hidden on all children? Let me know and I'll take a look.
regards,David Young
Hi David,
the first thing I do is to hide the default group by-column I defined for the grid in the GroupedRowInitialized event as the data of this column is displayed in the group row and therefore unnecessarily uses up space in the details row. There I use:WebHierarchicalDataGridDetails.GridView.Columns(0).Hidden = TruebecauseWebHierarchicalDataGridDetails.Bands(0).Columns(0).Hidden = Truedoes not work. That's why I tried to go the way over the GridView element also for band 1.
Yes, I want to hide the complete column in all children.
And regarding the event I use to hide the columns in band 1, I tried all that looked promising, but without luck. It is not needed at a special moment in the lifecycle of the page or the control, I just want to hide some columns if some criteria of the logged in user do not match when the page loads.
Regards,Andreas
I opened a regular support request for this.
This is how the WHDG is expected to behave. The row islands are stored in the view state once one is made, so change to the Band will not necessarily automatically be reflected in the row island until it is remade. You can use the following code snippet if you want to hide a column if the data is retrieved when you expand the parent band:
protected void WebHierarchicalDataGrid1_RowIslandDataBound(object sender, RowIslandEventArgs e) { for (int x = 0; x < e.RowIsland.Columns.Count; ++x) { if (x < e.RowIsland.Band.Columns.Count) e.RowIsland.Columns[x].Hidden = e.RowIsland.Band.Columns[x].Hidden; } }
Or if you are initially loading all the child bands you can use the following code snippet:
WebHierarchicalDataGrid1.Bands[0].Columns[2].Hidden = true;
this.WebHierarchicalDataGrid1.RefreshBehaviors();
Please test and send me regarding any questions.
Magued
My InitialDataBindDepth is set to 0 so I'm not binding the children when the parent is loaded. When I try and access the columns in the RowIslandDataBound event, my columns collection is empty. I'm autogenerating columns and want to hide two of them. Any suggestions?