or
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.1<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>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();}public class Item{ public int? IdGroup; public string Description; public string Type; public int? IdGroupParent; public int? IdItem;}

<div class="section"> <script type="text/javascript"> function setCustomPosition(sender, args) { sender.moveTo(sender.get_left(), sender.get_top()); } </script> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" onajaxrequest="RadAjaxManager1_AjaxRequest" > <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadListView1" UpdatePanelCssClass="" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadWindow ID="FVPopup" runat="server" Width="500px" Height="200px" Modal="true" OnClientShow="setCustomPosition" Top="20" Left="50"> <ContentTemplate> <asp:FormView CssClass="securityFormView" ID="FormView1" runat="server" DefaultMode="Insert" DataKeyNames="msgID" DataSourceID="SqlDataSource2"> <EditItemTemplate> Title: <asp:TextBox ID="titleTextBox" runat="server" Text='<%# Bind("title") %>' /> <br /> Message: <asp:TextBox ID="messageTextBox" runat="server" Text='<%# Bind("message") %>' /> <br /> hasBeenBroadcast: <asp:CheckBox ID="hasBeenBroadcastCheckBox" runat="server" Checked='<%# Bind("hasBeenBroadcast") %>' /> <br /> createdDate: <asp:Label ID="createdDateLabel" runat="server" Text='<%# Bind("createdDate") %>' /> <br /> <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </EditItemTemplate> <InsertItemTemplate> Title: <asp:TextBox ID="titleTextBox" runat="server" Text='<%# Bind("title") %>' /> <br /> Message: <asp:TextBox ID="messageTextBox" runat="server" Text='<%# Bind("message") %>' /> <br /> <telerik:RadButton OnClientClicked="closePopupModality" ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" CausesValidation="true" /> <telerik:RadButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </InsertItemTemplate> <ItemTemplate> title: <asp:Label ID="titleLabel" runat="server" Text='<%# Bind("title") %>' /> <br /> message: <asp:Label ID="messageLabel" runat="server" Text='<%# Bind("message") %>' /> <br /> hasBeenBroadcast: <asp:CheckBox ID="hasBeenBroadcastCheckBox" runat="server" Checked='<%# Bind("hasBeenBroadcast") %>' Enabled="false" /> <br /> createdDate: <asp:Label ID="createdDateLabel" runat="server" Text='<%# Bind("createdDate") %>' /> <br /> msgID: <asp:Label ID="msgIDLabel" runat="server" Text='<%# Eval("msgID") %>' /> <br /> <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" /> <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" /> <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" /> </ItemTemplate> </asp:FormView> </ContentTemplate> </telerik:RadWindow> <telerik:RadCodeBlock runat="server" ID="rdbScripts"> <script type="text/javascript"> function togglePopupModality() { var wnd = $find("<%=FVPopup.ClientID %>"); wnd.set_modal(!wnd.get_modal()); if (!wnd.get_modal()) document.documentElement.focus(); } function closePopupModality() { var wnd = $find("<%=FVPopup.ClientID %>"); wnd.close(); var ajaxMan= $find("<%=RadAjaxManager1.ClientID %>") ajaxMan.ajaxRequest("Rebind"); } </script> </telerik:RadCodeBlock> <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" Skin="Office2010Blue" /> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NSMCWebConnectionString %>" DeleteCommand="DELETE FROM [ISAdminSecurity] WHERE [msgID] = @msgID" InsertCommand="INSERT INTO [ISAdminSecurity] ([title], [message], [hasBeenBroadcast], [createdDate]) VALUES (@title, @message, @hasBeenBroadcast, GETDATE())" SelectCommand="SELECT [title], [message], [hasBeenBroadcast], [createdDate], [msgID] FROM [ISAdminSecurity] ORDER BY [createdDate]" UpdateCommand="UPDATE [ISAdminSecurity] SET [title] = @title, [message] = @message, [hasBeenBroadcast] = @hasBeenBroadcast, [createdDate] = @createdDate WHERE [msgID] = @msgID"> <DeleteParameters> <asp:Parameter Name="msgID" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="title" Type="String" /> <asp:Parameter Name="message" Type="String" /> <asp:Parameter Name="hasBeenBroadcast" Type="Boolean" DefaultValue="False" /> <asp:Parameter Name="createdDate" Type="DateTime" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="title" Type="String" /> <asp:Parameter Name="message" Type="String" /> <asp:Parameter Name="hasBeenBroadcast" Type="Boolean" /> <asp:Parameter Name="createdDate" Type="DateTime" /> <asp:Parameter Name="msgID" Type="Int32" /> </UpdateParameters> </asp:SqlDataSource> <telerik:RadListView ID="RadListView1" runat="server" AllowPaging="True" DataKeyNames="msgID" DataSourceID="SqlDataSource1" AllowNaturalSort="True" InsertItemPosition="FirstItem" Skin="Office2010Blue"> <LayoutTemplate> <div class="RadListView RadListView_Office2010Blue"> <table cellspacing="0" style="width: 100%;"> <thead> <tr class="rlvHeader"> <th> <telerik:RadButton AutoPostBack="false" OnClientClicked="togglePopupModality" ID="AddNewItem" runat="server" Text="Add New" /> </th> <th> title </th> <th> message </th> <th> hasBeenBroadcast </th> <th> createdDate </th> <th> msgID </th> </tr> </thead> <tfoot> <tr> <td colspan="6"> <telerik:RadDataPager ID="RadDataPager1" runat="server" SEOPagingQueryPageKey="" Skin="Office2010Blue"> <Fields> <telerik:RadDataPagerButtonField FieldType="FirstPrev" LastButtonImageUrl="" NextButtonImageUrl="" PrevButtonImageUrl="" /> <telerik:RadDataPagerButtonField FieldType="NextLast" LastButtonImageUrl="" NextButtonImageUrl="" PrevButtonImageUrl="" /> </Fields> </telerik:RadDataPager> </td> </tr> </tfoot> <tbody> <tr id="itemPlaceholder" runat="server"> </tr> </tbody> </table> <div style="display: none"> <telerik:RadCalendar ID="rlvSharedCalendar" runat="server" RangeMinDate="<%#new DateTime(1900, 1, 1) %>" Skin="<%#Container.Skin %>" /> </div> <div style="display: none"> <telerik:RadTimeView ID="rlvSharedTimeView" runat="server" Skin="<%# Container.Skin %>" /> </div> </div> </LayoutTemplate> <ItemTemplate> <tr class="rlvI"> <td> <asp:Button ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" CssClass="rlvBDel" Text=" " ToolTip="Delete" /> <asp:Button ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" CssClass="rlvBEdit" Text=" " ToolTip="Edit" /> </td> <td> <asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>' /> </td> <td> <asp:Label ID="messageLabel" runat="server" Text='<%# Eval("message") %>' /> </td> <td> <asp:CheckBox ID="hasBeenBroadcastCheckBox" runat="server" Checked='<%# Eval("hasBeenBroadcast") %>' Enabled="false" /> </td> <td> <asp:Label ID="createdDateLabel" runat="server" Text='<%# Eval("createdDate") %>' /> </td> <td> <asp:Label ID="msgIDLabel" runat="server" Text='<%# Eval("msgID") %>' /> </td> </tr> </ItemTemplate> <AlternatingItemTemplate> <tr class="rlvA"> <td> <asp:Button ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" CssClass="rlvBDel" Text=" " ToolTip="Delete" /> <asp:Button ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" CssClass="rlvBEdit" Text=" " ToolTip="Edit" /> </td> <td> <asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>' /> </td> <td> <asp:Label ID="messageLabel" runat="server" Text='<%# Eval("message") %>' /> </td> <td> <asp:CheckBox ID="hasBeenBroadcastCheckBox" runat="server" Checked='<%# Eval("hasBeenBroadcast") %>' Enabled="false" /> </td> <td> <asp:Label ID="createdDateLabel" runat="server" Text='<%# Eval("createdDate") %>' /> </td> <td> <asp:Label ID="msgIDLabel" runat="server" Text='<%# Eval("msgID") %>' /> </td> </tr> </AlternatingItemTemplate> <EditItemTemplate> <tr class="rlvIEdit"> <td colspan="6"> <table cellspacing="0" class="rlvEditTable"> <tr> <td> <asp:Label ID="titleLabel2" runat="server" AssociatedControlID="titleTextBox" Text="title"></asp:Label> </td> <td> <asp:TextBox ID="titleTextBox" runat="server" CssClass="rlvInput" Text='<%# Bind("title") %>' /> </td> </tr> <tr> <td> <asp:Label ID="messageLabel2" runat="server" AssociatedControlID="messageTextBox" Text="message"></asp:Label> </td> <td> <asp:TextBox ID="messageTextBox" runat="server" CssClass="rlvInput" Text='<%# Bind("message") %>' /> </td> </tr> <tr> <td> <asp:Label ID="hasBeenBroadcastLabel2" runat="server" AssociatedControlID="hasBeenBroadcastCheckBox" Text="hasBeenBroadcast"></asp:Label> </td> <td> <asp:CheckBox ID="hasBeenBroadcastCheckBox" runat="server" Checked='<%# Bind("hasBeenBroadcast") %>' /> </td> </tr> <tr> <td> <asp:Label ID="createdDateLabel2" runat="server" AssociatedControlID="createdDateTextBox" Text="createdDate"></asp:Label> </td> <td> <telerik:RadDateTimePicker ID="createdDateTextBox" runat="server" DbSelectedDate='<%# Bind("createdDate") %>' MinDate="<%#new DateTime(1900, 1, 1) %>" SharedCalendarID='<%# Container.OwnerListView.FindControl("rlvSharedCalendar").UniqueID %>' SharedTimeViewID='<%# Container.OwnerListView.FindControl("rlvSharedTimeView").UniqueID %>' Skin="<%#Container.OwnerListView.Skin %>" /> </td> </tr> <tr> <td> <asp:Label ID="msgIDLabel2" runat="server" Text="msgID"></asp:Label> </td> <td> <asp:Label ID="msgIDLabel1" runat="server" Text='<%# Eval("msgID") %>' /> </td> </tr> <tr> <td colspan="2"> <asp:Button ID="UpdateButton" runat="server" CommandName="Update" CssClass="rlvBUpdate" Text=" " ToolTip="Update" /> <asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="rlvBCancel" Text=" " ToolTip="Cancel" /> </td> </tr> </table> </td> </tr> </EditItemTemplate> <InsertItemTemplate> <tr class="rlvIEdit"> <td colspan="6"> <table cellspacing="0" class="rlvEditTable"> <tr> <td> <asp:Label ID="titleLabel2" runat="server" AssociatedControlID="titleTextBox" Text="title"></asp:Label> </td> <td> <asp:TextBox ID="titleTextBox" runat="server" CssClass="rlvInput" Text='<%# Bind("title") %>' /> </td> </tr> <tr> <td> <asp:Label ID="messageLabel2" runat="server" AssociatedControlID="messageTextBox" Text="message"></asp:Label> </td> <td> <asp:TextBox ID="messageTextBox" runat="server" CssClass="rlvInput" Text='<%# Bind("message") %>' /> </td> </tr> <tr> <td> <asp:Label ID="hasBeenBroadcastLabel2" runat="server" AssociatedControlID="hasBeenBroadcastCheckBox" Text="hasBeenBroadcast"></asp:Label> </td> <td> <asp:CheckBox ID="hasBeenBroadcastCheckBox" runat="server" Checked='<%# Bind("hasBeenBroadcast") %>' /> </td> </tr> <tr> <td> <asp:Label ID="createdDateLabel2" runat="server" AssociatedControlID="createdDateTextBox" Text="createdDate"></asp:Label> </td> <td> <telerik:RadDateTimePicker ID="createdDateTextBox" runat="server" DbSelectedDate='<%# Bind("createdDate") %>' MinDate="<%#new DateTime(1900, 1, 1) %>" SharedCalendarID='<%# Container.OwnerListView.FindControl("rlvSharedCalendar").UniqueID %>' SharedTimeViewID='<%# Container.OwnerListView.FindControl("rlvSharedTimeView").UniqueID %>' Skin="<%#Container.OwnerListView.Skin %>" /> </td> </tr> <tr> <td colspan="2"> <asp:Button ID="PerformInsertButton" runat="server" CommandName="PerformInsert" CssClass="rlvBAdd" Text=" " ToolTip="Insert" /> <asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="rlvBCancel" Text=" " ToolTip="Cancel" /> </td> </tr> </table> </td> </tr> </InsertItemTemplate> <EmptyDataTemplate> <div class="RadListView RadListView_Office2010Blue"> <div class="rlvEmpty"> There are no items to be displayed.</div> </div> </EmptyDataTemplate> <ValidationSettings EnableModelValidation="False" EnableValidation="False" /> <SelectedItemTemplate> <tr class="rlvISel"> <td> <asp:Button ID="DeselectButton" runat="server" CausesValidation="False" CommandName="Deselect" CssClass="rlvBSel" Text=" " ToolTip="Deselect" /> <asp:Button ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" CssClass="rlvBDel" Text=" " ToolTip="Delete" /> <asp:Button ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" CssClass="rlvBEdit" Text=" " ToolTip="Edit" /> </td> <td> <asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>' /> </td> <td> <asp:Label ID="messageLabel" runat="server" Text='<%# Eval("message") %>' /> </td> <td> <asp:CheckBox ID="hasBeenBroadcastCheckBox" runat="server" Checked='<%# Eval("hasBeenBroadcast") %>' Enabled="false" /> </td> <td> <asp:Label ID="createdDateLabel" runat="server" Text='<%# Eval("createdDate") %>' /> </td> <td> <asp:Label ID="msgIDLabel" runat="server" Text='<%# Eval("msgID") %>' /> </td> </tr> </SelectedItemTemplate> </telerik:RadListView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NSMCWebConnectionString %>" DeleteCommand="DELETE FROM [ISAdminSecurity] WHERE [msgID] = @msgID" InsertCommand="INSERT INTO [ISAdminSecurity] ([title], [message], [hasBeenBroadcast], [createdDate]) VALUES (@title, @message, @hasBeenBroadcast, @createdDate)" SelectCommand="SELECT [title], [message], [hasBeenBroadcast], [createdDate], [msgID] FROM [ISAdminSecurity] ORDER BY [createdDate]" UpdateCommand="UPDATE [ISAdminSecurity] SET [title] = @title, [message] = @message, [hasBeenBroadcast] = @hasBeenBroadcast, [createdDate] = @createdDate WHERE [msgID] = @msgID"> <DeleteParameters> <asp:Parameter Name="msgID" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="title" Type="String" /> <asp:Parameter Name="message" Type="String" /> <asp:Parameter Name="hasBeenBroadcast" Type="Boolean" /> <asp:Parameter Name="createdDate" Type="DateTime" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="title" Type="String" /> <asp:Parameter Name="message" Type="String" /> <asp:Parameter Name="hasBeenBroadcast" Type="Boolean" /> <asp:Parameter Name="createdDate" Type="DateTime" /> <asp:Parameter Name="msgID" Type="Int32" /> </UpdateParameters> </asp:SqlDataSource> </div>
if (e.eventDays.Contains("M")) days += 2;if (e.eventDays.Contains("T")) days += 4;if (e.eventDays.Contains("W")) days += 8;if (e.eventDays.Contains("R")) days += 16;if (e.eventDays.Contains("F")) days += 32; var dayMask = (RecurrenceDay)days; //Used to display recurrence schedule on the telerik scheduler