Im trying to get the values for sub columns in multi-column header grid.The markup is my grid below. I need to get teh value for "Q1Var".
Using this code in Initialize_Row says it cant find "Q1Var". Seems like It finds "QTR1" but not it sub columns.
e.Row.Items(Me.WdgCurrYear.Column("Q1Var").Index).Text = NumberFormatting.FormatData(e.Row.Items(Me.WdgCurrYear.Column("Q1Var").Index).Text, False, 2, True)
I will need to use this when they submit too. So a way to access these columns would be appreciated
<ig:WebDataGrid ID="WdgCurrYear" runat="server" AutoGenerateColumns="False" StyleSetName="WestonBlue"> <Columns> <ig:BoundDataField DataFieldName="FY_CD" DataType="System.String" Hidden="True" Key="FY_CD"> <Header Text="YEAR" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="METRIC_ID" Hidden="True" Key="METRIC_ID"> <Header Text="Metric ID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="METRIC_DESC" Key="METRIC_DESC"> <Header Text="Metric" /> </ig:BoundDataField> <ig:GroupField Key="QTR1" Header-CssClass="Multi_Col1"> <Header Text="Q1" /> <Columns> <ig:BoundDataField DataFieldName="Q1Plan" Key="Q1Plan" Header-CssClass="Single_Col" CssClass="igg_WestonBlueItemRAlign"> <Header Text="Plan" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Q1amt" Key="Q1amt" Header-CssClass="Single_Col_Bot" CssClass="igg_WestonBlueItemRAlign"> <Header Text="Amt" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Q1Var" Key="Q1Var" CssClass="DisableRow igg_WestonBlueItemRAlign" Header-CssClass="Single_Col_Bot" > <Header Text="Var" /> <Footer CssClass="Class1" /> </ig:BoundDataField> </Columns> </ig:GroupField> <ig:GroupField Key="QTR2" Header-CssClass="Multi_Col1"> <Header Text="Q2" /> <Columns> <ig:BoundDataField DataFieldName="Q2Plan" Key="Q2Plan" Header-CssClass="Single_Col" CssClass="igg_WestonBlueItemRAlign"> <Header Text="Plan" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Q2amt" Key="Q2amt" Header-CssClass="Single_Col_Bot" CssClass="igg_WestonBlueItemRAlign"> <Header Text="Amt" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Q2Var" Key="Q2Var" CssClass="DisableRow igg_WestonBlueItemRAlign" Header-CssClass="Single_Col_Bot"> <Header Text="Var" /> </ig:BoundDataField> </Columns> </ig:GroupField> <ig:GroupField Key="QTR3" Header-CssClass="Multi_Col1"> <Header Text="Q3" /> <Columns> <ig:BoundDataField DataFieldName="Q3Plan" Key="Q3Plan" Header-CssClass="Single_Col" CssClass="igg_WestonBlueItemRAlign"> <Header Text="Plan" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Q3amt" Key="Q3amt" Header-CssClass="Single_Col_Bot" CssClass="igg_WestonBlueItemRAlign"> <Header Text="Amt" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Q3Var" Key="Q3Var" CssClass="DisableRow igg_WestonBlueItemRAlign" Header-CssClass="Single_Col_Bot"> <Header Text="Var" /> </ig:BoundDataField> </Columns> </ig:GroupField> <ig:GroupField Key="QTR4" Header-CssClass="Multi_Col1"> <Header Text="Q4" /> <Columns> <ig:BoundDataField DataFieldName="Q4Plan" Key="Q4Plan" Header-CssClass="Single_Col" CssClass="igg_WestonBlueItemRAlign"> <Header Text="Plan" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Q4amt" Key="Q4amt" Header-CssClass="Single_Col_Bot" CssClass="igg_WestonBlueItemRAlign"> <Header Text="Amt" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Q4Var" Key="Q4Var" CssClass="DisableRow igg_WestonBlueItemRAlign" Header-CssClass="Single_Col_Bot"> <Header Text="Var" /> </ig:BoundDataField> </Columns> </ig:GroupField> <ig:GroupField Key="Year" Header-CssClass="Multi_Col2"> <Header Text="Year" /> <Columns> <ig:BoundDataField DataFieldName="YrPlan" Key="YrPlan" CssClass="DisableRow igg_WestonBlueItemRAlign" Header-CssClass="Single_Col"> <Header Text="Plan" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="YrAmt" Key="YrAmt" CssClass="DisableRow igg_WestonBlueItemRAlign" Header-CssClass="Single_Col_Bot"> <Header Text="Amt" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="YrVar" Key="YrVar" CssClass="DisableRow igg_WestonBlueItemRAlign" Header-CssClass="Single_Col2"> <Header Text="Var" /> </ig:BoundDataField> </Columns> </ig:GroupField> <ig:BoundDataField DataFieldName="COMMENT" Key="COMMENT"> <Header Text="Comments" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Calculation" Hidden="True" Key="Calculation"> <Header Text="Calculation" /> </ig:BoundDataField> </Columns> <Behaviors> <ig:EditingCore> <Behaviors> <ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="Q1Var" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="Q2Var" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="Q3Var" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="Q4Var" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="YrPlan" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="YrAmt" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="YrVar" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="METRIC_DESC" ReadOnly="True" /> </ColumnSettings> <EditModeActions MouseClick="Single" /> <CellEditingClientEvents EnteringEditMode="WebDataGridView_EnteringEditMode" /> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebDataGrid>Steve Zelonis
Hi Steve,
It looks like you are using VB. I'll give the answer in VB and it should be simple to change it. Basically, the Columns collection on the grid is only the top level columns (your metric, Q1, Q2, Q3, Q4, and comment). If you want to find a sub column, you can either cast Q1 to a GroupField and get it out of its Columns collection, or the grid itself has a method to find a column based on a key (foreseeing this type of problem). Its called FindColumn and accepts a string.
this.WdgCurrYear.FindColumn("Q1Var")
That should be what you're looking for.
regards,David Young
Thanks for the response. But how would in WdgCurrYear_LoadAccess these columns. I need to set style sheets on these columns based on data from the Database. I want to do something like this:
Me.WdgCurrYear.Columns("Q1amt").CssClass = "DisableRow"Currently I get
Any Suggestions would be great
Thanks
Steve Zelonis