This is a migrated thread and some comments may be shown as answers.

Radgrid Child table paging issues

1 Answer 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Narendra
Top achievements
Rank 1
Narendra asked on 05 Jan 2009, 08:26 PM
I have a grid with Detail Tables into it. Master table is category which just displays category name and child table displays records for that related parent category. Detail table has 5 columns. Not when I try to implement paging it doesn't work. It never finds the correct number of pages so it doesn't show the Pager controls properly.
Even though each category has more than 2 records (PageSize=2). It doesn't display more than 1 page in paging control.
What seems to be wrong here?

Here is grid in ASPX page
    <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>

And here is related some (C#) code 
        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;
        }

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 08 Jan 2009, 02:32 PM
Hello Narendra,

From the code snippet you provided I see that you set AllowCustomPaging = true instead of AllowPaging = true and PageSize = 2 for your GridTableView instance. Can this be the reason for the abnormality you encountered?

In case you would like to implement custom paging for your detail table, review the following online resources which elaborate on how this can be accomplished:

http://demos.telerik.com/aspnet-ajax/Grid/Examples/Programming/CustomPaging/DefaultCS.aspx
http://www.telerik.com/help/aspnet-ajax/grdcustompaging.html

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Narendra
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or