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
Hi Magued,
in the RowIslandDataBound event, e.RowIsland does not exist.
It does exist in RowIslandDataBinding. But there this code does not do anything :-/
Can you test it yourself?
I have looked at the event and the object e.RowIsland exists. If you would like an easier approach then you can call the method RefreshBehaviors() available on the WebHierarchicalDataDrid level after you hide the column.
have you checked it in Visual Studio?
My Visual Studio 2008 insists that e.RowIsland is no member of "System.EventArgs" (I'm using VB.NET).
Ok, it works. Thanks!
If your question is how to hide and unhide a grouped column then you can use the GroupedColumnsChanging event similar to the following code snippet:
protected void WebHierarchicalDataGrid1_GroupedColumnsChanging(object sender, GroupedColumnsChangingEventArgs e)
{
if (e.Action == GroupByChangeAction.Group)
foreach (GroupedColumn col in e.EffectedColumns)
e.Band.Columns[col.ColumnKey].Hidden = true;
if (e.Action == GroupByChangeAction.Ungroup)
e.Band.Columns[col.ColumnKey].Hidden = false;
}
Sorry, it indeed exists in this event and it hides columns.:-)
I only have to find out how I can limit the effect on the lowest band level, depending on how group by is used by the user.