Hi everyone,
How Can I create my radgrid subdivided by groups and subgroups with structure generated dynamically?
For example, considering the following scenario: I have one item list that represent this structure of groups
and subgroups and I need to do bind it in the radgrid.
Group1|________Item1.1|________SubGroup1.1| |________Item1.1.1| |________SubGroup1.1.1|________SubGroup1.2|________SubGroup1.3 |________Item1.3.1Group2|________Subgroup2.1
Group1|________Item1.1|________SubGroup1.1|________SubGroup1.2|________SubGroup1.3Group2|________Subgroup2.1Below is my radgrid
<telerik:RadGrid ID="radGrid" Width="100%" Skin="Silk" AllowSorting="True" ShowFooter="true"AllowPaging="True" runat="server" AutoGenerateColumns="False" ShowStatusBar="True"
AllowMultiRowSelection="true"EnableLinqExpressions="False" CellSpacing="0" GridLines="None" OnItemCommand="radGrid_ItemCommand" OnItemDataBound="radGrid_ItemDataBound" ><ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true" AllowGroupExpandCollapse="true"
ReorderColumnsOnClient="true" ColumnsReorderMethod="Reorder" EnableRowHoverStyle="true"> <Selecting AllowRowSelect="true"/> <Animation AllowColumnReorderAnimation="true" AllowColumnRevertAnimation="true"> </Animation
</ClientSettings>
<MasterTableView DataSourceID="odsGrupoProduto" DataKeyNames="IdItem,IdGroup"
NoMasterRecordsText="Nenhum registro encontrado."> <Columns> <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" UniqueName="Description"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> </telerik:GridBoundColumn>
<telerik:GridTemplateColumn Reorderable="false" Resizable="false"> <ItemTemplate> <asp:ImageButton ID="ibEditSubGroup" runat="server"
ToolTip="Edit SubGroup." CommandArgument='<%# Eval("IdGroup")%>'
CommandName="Edit"
ImageUrl="~/imagems/edit.png" /> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn Reorderable="false" Resizable="false"> <ItemTemplate> <asp:ImageButton ID="ibRemove" runat="server" ToolTip="Remove item." CommandArgument='<%# Eval("IdItem")%>'
CommandName="Remove"
ImageUrl="~/imagems/delete.png" /> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> </telerik:GridTemplateColumn> </Columns> </MasterTableView>
</telerik:RadGrid>
<asp:ObjectDataSource ID="ods" runat="server" SelectMethod="ListItems"TypeName="ControllerGroup">
</asp:ObjectDataSource>I set GridGroupByExpression in the method that load my radgrid:
private void LoadGrid(){ ods.SelectParameters.Clear(); radGrid.DataSourceID = "ods"; ods.DataBind(); GridGroupByExpression expression1 = GridGroupByExpression.Parse("Type Group By Type"); this.radGrid.MasterTableView.GroupByExpressions.Add(expression1); radGrid.Rebind();}Below is my class of item of list
public class Item{ public int? IdGroup; public string Description; public string Type; public int? IdGroupParent; public int? IdItem;}
Please, give me ideas about how can I resolve this issue!
Thanks!
