I have a grid with a single Detail Table into it.
Basically, master table is category which just displays category name and detail table displays records for that related parent category.
Detail table has 5 columns. Evenrything is fine but paging in detail table is not working.
Even though each category has more than 2 records with PageSize=2; it doesn't display more than 1 page in paging control.
What seems to be wrong here? Appreciate any help!!
~Narendra
ASPX:
| <telerik:RadGrid ID="RadGridParent" runat="server" EnableAJAX="True" GridLines="None" | |
| ShowGroupPanel="True" Skin="Office2007" AutoGenerateColumns="False" Description="Messages" | |
| ShowStatusBar="True" Subtitle="Messages" Title="Messages" Width="98%" | |
| OnItemCommand="RadGridParent_ItemCommand" ShowHeader="False" | |
| PagerStyle-AlwaysVisible="False" AllowPaging="True" PageSize="2" | |
| OnDetailTableDataBind="RadGridParent_DetailTableDataBind" | |
| onitemdatabound="RadGridParent_ItemDataBound" | |
| onneeddatasource="RadGridParent_NeedDataSource" | |
| onprerender="RadGridParent_PreRender" AllowSorting="True" | |
| AllowMultiRowSelection="True"> | |
| <MasterTableView DataKeyNames="CategoryID" CommandItemDisplay="Top"> | |
| <DetailTables> | |
| <telerik:GridTableView runat="server" DataKeyNames="CategoryID" | |
| AutoGenerateColumns="False" GridLines="Both" | |
| CommandItemDisplay="Bottom" AllowAutomaticInserts="false" AllowAutomaticUpdates="false" | |
| HierarchyLoadMode="ServerOnDemand" ShowHeader="True" | |
| PagerStyle-AlwaysVisible="True" AllowCustomPaging="True" | |
| BorderStyle="Ridge" Width="100%" | |
| NoDetailRecordsText="There are no messages." > | |
| <ParentTableRelation> | |
| <telerik:GridRelationFields DetailKeyField="CategoryID" MasterKeyField="CategoryID" /> | |
| </ParentTableRelation> | |
| <RowIndicatorColumn Visible="false"> | |
| <HeaderStyle Width="20px" /> | |
| </RowIndicatorColumn> | |
| <ExpandCollapseColumn Resizable="False"> | |
| <HeaderStyle Width="20px" /> | |
| </ExpandCollapseColumn> | |
| <PagerStyle Mode="NumericPages"></PagerStyle> | |
| <CommandItemTemplate> | |
| <div> | |
| <table border=0 cellspacing=0 cellpadding=0 width="100%"> | |
| <tr> | |
| <td width="40%"> | |
| <div style="float:left;"> | |
| <asp:LinkButton ID="btnDeleteMessage" ConfirmText="Sure?" runat="server" Text="Delete Selected" CommandName="MessageDelete" OnClientClick="return ConfirmDelete(this);" SkinId="swGridDeleteSelectedLinkButton"> </asp:LinkButton> | |
| </div> | |
| </td> | |
| <td width="20%"> | |
| <div style="float:left;"> | |
| <asp:LinkButton ID="btnMessageMarkAsRead" runat="server" Text="Mark Selected as Read" CommandName="MessageMarkRead" SkinId="swGridMarkMessageReadLinkButton"> </asp:LinkButton> | |
| </div> | |
| </td> | |
| <td width="40%"> | |
| <div style="float:right;"> | |
| <asp:LinkButton ID="btnMessageMarkAsUnread" runat="server" Text="Mark Selected as Unread" CommandName="MessageMarkUnread" SkinId="swGridMarkMessageUnreadLinkButton"></asp:LinkButton> | |
| </div> | |
| </td> | |
| </tr> | |
| </table> | |
| </div> | |
| </CommandItemTemplate> | |
| <Columns> | |
| <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderText="Select All"> | |
| <HeaderStyle Width="10px" /> | |
| </telerik:GridClientSelectColumn> | |
| <telerik:GridBoundColumn DataField="IsRead" DataType="System.String" HeaderText="" Groupable="false" | |
| SortExpression="IsRead" UniqueName="MessageReadIcon" Visible="True"> | |
| <HeaderStyle Width="10px" /> | |
| <ItemStyle Width="10px" /> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="CategoryID" DataType="System.Int32" Groupable="false" | |
| ReadOnly="True" SortExpression="NotificationMsgID" UniqueName="NotificationMsgID" Visible="False"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="NotificationMsgUserID" DataType="System.Int32" Groupable="false" | |
| ReadOnly="True" SortExpression="NotificationMsgUserID" UniqueName="NotificationMsgUserID" Visible="False"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="RVNotificationMsgUser" DataType="System.Int32" Groupable="false" | |
| ReadOnly="True" UniqueName="RVNotificationMsgUser" Visible="False"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="Topic" HeaderText="Topic" DataType="System.String" Groupable="false" | |
| SortExpression="Topic" UniqueName="Topic"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="SendDate" DataType="System.DateTime" Groupable="false" | |
| HeaderText="Date" SortExpression="SendDate" UniqueName="SendDate"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="Sender" DataType="System.String" HeaderText="From" Groupable="false" | |
| SortExpression="Sender" UniqueName="Sender"> | |
| <ItemStyle Width="140px" /> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="MessageText" DataType="System.String" HeaderText="Message" Groupable="false" SortExpression="MessageText" | |
| UniqueName="MessageText"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="SenderUserLastName" UniqueName="SenderUserLastName" Groupable="false" Visible="False"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="SenderUserFirstName" UniqueName="SenderUserFirstName" Groupable="false" Visible="False"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="SenderUserMiddleName" UniqueName="SenderUserMiddleName" Groupable="false" Visible="False"> | |
| </telerik:GridBoundColumn> | |
| </Columns> | |
| <editformsettings> | |
| <popupsettings scrollbars="None" /> | |
| </editformsettings> | |
| </telerik:GridTableView> | |
| </DetailTables> | |
| <editformsettings> | |
| <popupsettings scrollbars="None" /> | |
| </editformsettings> | |
| <CommandItemTemplate> | |
| <div style="float:right;text-align:right"> | |
| <asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid" | |
| SkinID="swGridRefreshLinkButton" Text="Refresh" ToolTip="Refresh"> </asp:LinkButton> | |
| </div> | |
| </CommandItemTemplate> | |
| <RowIndicatorColumn Visible="False"> | |
| <HeaderStyle Width="20px"></HeaderStyle> | |
| </RowIndicatorColumn> | |
| <ExpandCollapseColumn Visible="true" Resizable="False"> | |
| <HeaderStyle Width="20px"></HeaderStyle> | |
| </ExpandCollapseColumn> | |
| <Columns> | |
| <telerik:GridBoundColumn DataField="MessageDescription" HeaderText="Messages" | |
| SortExpression="MessageDescription" UniqueName="MessageDescription" | |
| ItemStyle-Font-Bold="true" Groupable="false"> | |
| <ItemStyle Font-Bold="True" /> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="CategoryID" UniqueName="CategoryID" HeaderText="" Visible="False"> | |
| </telerik:GridBoundColumn> | |
| </Columns> | |
| </MasterTableView> | |
| <GroupPanel ID="SystemWorksStandardGridGroupPanel" Text="Notifications"> | |
| <PanelStyle Width="100%" Height="20px" /> | |
| </GroupPanel> | |
| <ClientSettings AllowColumnsReorder="False" AllowDragToGroup="True" ReorderColumnsOnClient="False"> | |
| <Selecting AllowRowSelect="True" /> | |
| <Scrolling AllowScroll="false" UseStaticHeaders="false" /> | |
| </ClientSettings> | |
| <PagerStyle Mode="NumericPages"></PagerStyle> | |
| </telerik:RadGrid> | |
CS
| protected void RadGridMessages_NeedDataSource(object source, GridNeedDataSourceEventArgs e) | |
| { | |
| if (!e.IsFromDetailTable) | |
| { | |
| LoadParentData(); | |
| } | |
| } | |
| private void LoadParentData() | |
| { | |
| Category[] cats = new Category[2]; | |
| Category cat1= new Category(); | |
| cat1.MessageTypeID = 1; | |
| cat1.MessageDescription = "Catorogy 1"; | |
| cats [0] = cat1 ; | |
| cat1.MessageTypeID = 2; | |
| cat1.MessageDescription = "Category 2"; | |
| cats[1] = cat1; | |
| RadGridParent.MasterTableView.DataSource = cats; | |
| } | |
| protected void RadGridParent_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) | |
| { | |
| childDataSource[] childDS; | |
| GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem; | |
| int catId = Int32.Parse(dataItem.GetDataKeyValue("CategoryID").ToString()); | |
| childDS = GetChildDataSourceByCategory(catId); | |
| e.DetailTableView.DataSource = childDS; | |
| } | |