Hello,
i have radgrid with grouping on two levels, here is the aspx code:
...
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="Proces" FieldName="Proces" HeaderText="<%$ Resources:StartRes, Lb_Proces %>">
</telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="Proces" SortOrder="Descending"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="Postapka" FieldName="Postapka" HeaderText="<%$ Resources:StartRes, Lb_Predmet %>">
</telerik:GridGroupByField>
<telerik:GridGroupByField FieldAlias="BrPRedmet" FieldName="BrPRedmet" HeaderText="<%$ Resources:StartRes, BrPRedmet %>">
</telerik:GridGroupByField>
<telerik:GridGroupByField FieldAlias="DelSubjekt" FieldName="DelSubjekt" HeaderText="<%$ Resources:StartRes, Tv_DSubjekti %>">
</telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="BrPRedmet" SortOrder="Descending"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
...
On Page load i need all group columns to be collapsed, on the first and on the second level. In the code behind i have code to collapse the group columns on the first level. The problem is that i can't access the group columns on the second grouping level. With debugging i found that RadGrid1.MasterTableView.Controls[0].Controls[1].Controls are the group columns on the second level, but i don't know how to cast them so i can set Expand attribute to false. Here is the code that i use to collapse group columns on first level:
foreach (GridItem item in RadGrid1.MasterTableView.Controls[0].Controls)
{
item.Expanded = false;
}
If i try to access group columns on the second level with GridItem cast
foreach (GridItem item in RadGrid1.MasterTableView.Controls[0].Controls)
{
item.Expanded = false;
foreach (GridItem subitem in item.Controls[1].Controls)
{
}
}
i get the message
Unable to cast object of type 'Telerik.Web.UI.GridTableHeaderCell' to type 'Telerik.Web.UI.GridItem'.
Please help me how to cast the group columns on the second level so i can collapse them all on Page Load, or tell me some other solution for collapsing group columns.
Thank you and pardon my English, not that good.
i have radgrid with grouping on two levels, here is the aspx code:
...
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="Proces" FieldName="Proces" HeaderText="<%$ Resources:StartRes, Lb_Proces %>">
</telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="Proces" SortOrder="Descending"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="Postapka" FieldName="Postapka" HeaderText="<%$ Resources:StartRes, Lb_Predmet %>">
</telerik:GridGroupByField>
<telerik:GridGroupByField FieldAlias="BrPRedmet" FieldName="BrPRedmet" HeaderText="<%$ Resources:StartRes, BrPRedmet %>">
</telerik:GridGroupByField>
<telerik:GridGroupByField FieldAlias="DelSubjekt" FieldName="DelSubjekt" HeaderText="<%$ Resources:StartRes, Tv_DSubjekti %>">
</telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="BrPRedmet" SortOrder="Descending"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
...
On Page load i need all group columns to be collapsed, on the first and on the second level. In the code behind i have code to collapse the group columns on the first level. The problem is that i can't access the group columns on the second grouping level. With debugging i found that RadGrid1.MasterTableView.Controls[0].Controls[1].Controls are the group columns on the second level, but i don't know how to cast them so i can set Expand attribute to false. Here is the code that i use to collapse group columns on first level:
foreach (GridItem item in RadGrid1.MasterTableView.Controls[0].Controls)
{
item.Expanded = false;
}
If i try to access group columns on the second level with GridItem cast
foreach (GridItem item in RadGrid1.MasterTableView.Controls[0].Controls)
{
item.Expanded = false;
foreach (GridItem subitem in item.Controls[1].Controls)
{
}
}
i get the message
Unable to cast object of type 'Telerik.Web.UI.GridTableHeaderCell' to type 'Telerik.Web.UI.GridItem'.
Please help me how to cast the group columns on the second level so i can collapse them all on Page Load, or tell me some other solution for collapsing group columns.
Thank you and pardon my English, not that good.