I want to hide the first column in my WHDG, in code, when a certail condition occurs. I have a checkbox inside a template field as the first column. I have tried the following;
WebHierarchicalDataGrid.Columns(0).Hidden = True
This doesnt make any change at all when the page is loaded. The column is still visible.
I am using the grid to display a flat table with grouping allowed for certain columns (not the chkbox templated column of course).
Anyone have a clue as to how I can get this to work?
Hi hogleg,
Does hiding any other columns work? Or does it work if you hide it from the aspx? I know I've seen cases where column hiding does not work properly if the head does not have runat="server". Could you check that? Let me know.
regards,
David Young
David,
It works when I set hidden on the aspx. Doesn't otherwise, on any column, even a non template field.
head statement has runat server set appropriately.
<h
ead id="Head1" runat="server"><title>WebCTS Client Summary</title><script type="text/javascript" src="includes\windows.js"></script></head>
<CollapseButton AltText="Collapse Row"></CollapseButton>
<ExpandButton AltText="Expand Row"></ExpandButton> <Behaviors> <ig:Sorting> <ColumnSettings> <ig:SortingColumnSetting ColumnKey="BoundColumn_4" /> <ig:SortingColumnSetting ColumnKey="BoundColumn_6" /> <ig:SortingColumnSetting ColumnKey="BoundColumn_7" /> <ig:SortingColumnSetting ColumnKey="BoundColumn_8" /> </ColumnSettings> </ig:Sorting> </Behaviors> </ig:WebHierarchicalDataGrid>
this worked for me;
WebHierarchicalDataGrid.GridView.Columns(0).Hidden = True
Hi,
I kind of forgot that this was the HierarchicalGrid. If you set it on the WHDG itself, you are setting it on the band. You would have to call WebHierarchicalDataGrid.RefreshBehaviors() to get it down. Or you could set it yourself on WebHierarchicalDataGrid.GridView.Columns
-Dave
NOPE! that didnt help. hiding column still not working.
heres my corrected script where the behaviors sections were combined
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid" runat="server" Height="500px" Width="100%" AutoGenerateBands="False" AutoGenerateColumns="False" StyleSetName="Default" DataKeyFields="t4pkid" EnableDataViewState="True"> <GroupingSettings EnableColumnGrouping="True"> <ColumnSettings> <ig:ColumnGroupingSetting ColumnKey="BoundColumn_2" /> <ig:ColumnGroupingSetting ColumnKey="BoundColumn_3" /> <ig:ColumnGroupingSetting ColumnKey="BoundColumn_4" /> <ig:ColumnGroupingSetting ColumnKey="BoundColumn_6" /> <ig:ColumnGroupingSetting ColumnKey="BoundColumn_7" /> </ColumnSettings> <RemoveButton AltText="Ungroup Column"></RemoveButton> </GroupingSettings> <Columns> <ig:TemplateDataField Key="ItemSelector" Width="8px" > <ItemTemplate> <asp:CheckBox ID="chkItemSelector" runat="server" /> </ItemTemplate> </ig:TemplateDataField> <ig:BoundDataField DataFieldName="szVendorName" Key="BoundColumn_1"> <Header Text="Vendor" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="szVendStore" Key="BoundColumn_2"> <Header Text="Store" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="szSysType" Key="BoundColumn_3"> <Header Text="SysType" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="AppType" Key="BoundColumn_4"> <Header Text="AppType" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="type" Key="BoundColumn_5"> <Header Text="PullType" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="szCnvStatus" Key="BoundColumn_6"> <Header Text="Status" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="szCnvKStatus" Key="BoundColumn_7"> <Header Text="Supp Status" /> </ig:BoundDataField> <ig:TemplateDataField Key="BoundColumn_8" > <ItemTemplate> <asp:LinkButton ID="lnkSelect" runat="server" OnCommand="lnkSelect_OnCommand" CommandName="select" CommandArgument='<%# DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "t4pkid")%>' ><%# DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "t4pkid")%></asp:LinkButton> </ItemTemplate> <Header Text="CnvID" /> </ig:TemplateDataField> </Columns>
<ExpandButton AltText="Expand Row"></ExpandButton> <Behaviors> <ig:RowSelectors Enabled="false"></ig:RowSelectors> <ig:Sorting> <ColumnSettings> <ig:SortingColumnSetting ColumnKey="BoundColumn_4" /> <ig:SortingColumnSetting ColumnKey="BoundColumn_6" /> <ig:SortingColumnSetting ColumnKey="BoundColumn_7" /> <ig:SortingColumnSetting ColumnKey="BoundColumn_8" /> </ColumnSettings> </ig:Sorting> </Behaviors> </ig:WebHierarchicalDataGrid>
I just noticed that I have two behavior tags in the markup. Let me combine them. That surely cant be helping