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

Paging for Detail Table is not working

6 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raghunath
Top achievements
Rank 2
Raghunath asked on 03 Dec 2013, 09:26 AM
I am trying to paging for detail table in RadGrid. but when i click on page's it is getting back to grid bind.

My code is :-

  <telerik:RadGrid ID="rdSettings" runat="server" AllowPaging="true" width="100%" AutoGenerateColumns="false"
                        OnDetailTableDataBind="rdSettings_DetailTableDataBind" Skin="Metro" OnPageIndexChanged="rdSettings_PageIndexChanged" OnPageSizeChanged="rdSettings_PageSizeChanged" Visible="false">
                    <MasterTableView  DataKeyNames="Module">
                    <DetailTables>
                    <telerik:GridTableView Name="group" Width="100%" AutoGenerateColumns="false">
                      <Columns>
                        <telerik:GridTemplateColumn ItemStyle-Width="5%">
                           <ItemTemplate>
                                <asp:CheckBox ID="chkGroup" runat="server" AutoPostBack="true" OnCheckedChanged="chkGroup_CheckedChanged"/>
                          </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="groupname" UniqueName="groupname" HeaderText="Group" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                            </telerik:GridBoundColumn>
                      </Columns>
                    </telerik:GridTableView>
                    </DetailTables>
                         <Columns>
                            <telerik:GridTemplateColumn HeaderText="Select">
                                <HeaderTemplate>
                                    <asp:CheckBox ID="chkHeader" AutoPostBack="true" runat="server" OnCheckedChanged="chkHeader_CheckedChanged" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkmodule" runat="server" OnCheckedChanged="chkmodule_CheckedChanged" AutoPostBack="true" />
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="Module" UniqueName="Module" HeaderText="Module" ItemStyle-Width="85%" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                            </telerik:GridBoundColumn>
                         </Columns>
                    </MasterTableView>
                </telerik:RadGrid>



And Detail Table code is



protected void rdSettings_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e) // Bind's the nested Grid for Page Settings
    {
        string groupname = "";
        GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
        switch (e.DetailTableView.Name)
        {
            case "group":
                {
                    groupname = dataItem.GetDataKeyValue("Module").ToString();
                    string sqlquery = "select distinct(groupname) from [dbo].[POColumns] where module= '" + groupname + "'";
                    SqlDataAdapter da = new SqlDataAdapter(sqlquery, ScrCon);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        e.DetailTableView.DataSource = ds;
                    }
                    break;
                }
        }
    }


Please help out what else i have to do get the paging in Detail Table

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Dec 2013, 09:45 AM
Hi Raghunath,

I'm not clear about your issue, i guess you want paging in your detail table. Please try setting AllowPaging="true" and also try setting PageSize property in the GridTableView. Please try the following code snippet.

ASPX:
<telerik:GridTableView Name="group" Width="100%"  AutoGenerateColumns="false" AllowPaging="true" PageSize="5">

Thanks,
Princy

0
Raghunath
Top achievements
Rank 2
answered on 03 Dec 2013, 09:48 AM
But when i do allowpaging= "true" then i click on paging for detail table, the radgrid is firing the radgrid page index changed event. so that the grid is again binding and detail table getting closed.
0
Princy
Top achievements
Rank 2
answered on 03 Dec 2013, 09:53 AM
Hi Raghunath,

Can you please provide your full C# code so as to look into the OnPageIndexChanged and OnPageSizeChanged events.

Thanks,
Princy

0
Raghunath
Top achievements
Rank 2
answered on 03 Dec 2013, 09:56 AM
Hi,Thanks for your instant reply.. This is my full code ...


  protected void rdSettings_PageIndexChanged(object sender, GridPageChangedEventArgs e)
    {
        rdSettings.CurrentPageIndex = e.NewPageIndex;
        bindGrid();
    }
    protected void rdSettings_PageSizeChanged(object source, GridPageSizeChangedEventArgs e)
    {
        bindGrid();
    }


private void bindgrid()
{

string qry = "select BindGridQuery from BindOperations where Operation = 'Settings'";
            con.Open();
            SqlCommand cmd = new SqlCommand(qry, con);
            string query = cmd.ExecuteScalar().ToString();
            con.Close();
            if (query.Length > 0)
            {
                SqlDataAdapter da = new SqlDataAdapter(query, ScrCon);
                DataSet ds = new DataSet();
                da.Fill(ds);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    rdSettings.DataSource = ds;
                    rdSettings.DataBind();
                }
            }
}
0
Accepted
Princy
Top achievements
Rank 2
answered on 03 Dec 2013, 10:12 AM
Hi Raghunath,

Please bind the RadGrid using Advanced Data-binding (using NeedDataSource event). Also please take a look into this demo on Grid - Programmatic Hierarchy Binding. You don't have to bind the RadGrid each time when paging if you use NeedDataSource event for binding the RadGrid.

Thanks,
Princy
0
Raghunath
Top achievements
Rank 2
answered on 03 Dec 2013, 10:22 AM
Thank you so much. It worked for me....
Tags
Grid
Asked by
Raghunath
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Raghunath
Top achievements
Rank 2
Share this question
or