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

paging issue in Radgrid.

3 Answers 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Srikar
Top achievements
Rank 1
Srikar asked on 04 Jul 2013, 09:05 AM
Hi,

I have enabled paging in the "grdReportDataGrid" grid. Which is inside "RadGrid1" grid. When i navigating between "grdReportDataGrid" pages, "RadGrid1" is collapsing.

Expected output: "RadGrid1" should not collapse and user should see the request page in “grdReportDataGrid”


Here is the designer file.

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadSkinManager ID="RadSkinManager1" Skin="Black" ShowChooser="false" runat="server">
    </telerik:RadSkinManager>
    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All"
        EnableRoundedCorners="false" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="mainTab">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="mainTab" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
              <telerik:AjaxSetting AjaxControlID="mainTab">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="mainTabMultipages" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadTabStrip runat="server" ID="mainTab" MultiPageID="mainTabMultipages"
        SelectedIndex="0" OnTabClick="mainTab_TabClick">
        <Tabs>
            <telerik:RadTab runat="server" Text="Unit Test" PageViewID="pvUnitTest">
            </telerik:RadTab>
        </Tabs>
        <Tabs>
            <telerik:RadTab runat="server" Text="Static analysis" PageViewID="pvStaticAnalysis">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage runat="server" ID="mainTabMultipages" SelectedIndex="0" RenderSelectedPageOnly="false">
        <telerik:RadPageView runat="server" ID="pvUnitTest">
            <telerik:RadGrid AllowSorting="True" runat="server" ID="grdUnitTest" AutoGenerateColumns="true"
                ShowFooter="true" EnableLinqExpressions="false">
            </telerik:RadGrid>
        </telerik:RadPageView>
        <telerik:RadPageView runat="server" ID="pvStaticAnalysis">
            <telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1" runat="server" AllowSorting="True"
                PageSize="50" AllowMultiRowSelection="False" OnItemCommand="RadGrid1_ItemCommand"
                AllowPaging="True" GridLines="None" ShowGroupPanel="true">
                <PagerStyle Mode="NumericPages"></PagerStyle>
                <MasterTableView AllowMultiColumnSorting="True" GroupLoadMode="Server">
                    <NestedViewTemplate>
                        <asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap">
                            <telerik:RadTabStrip runat="server" ID="TabStip1" MultiPageID="Multipage1" SelectedIndex="0">
                                <Tabs>
                                    <telerik:RadTab runat="server" Text="Details" PageViewID="PageView1">
                                    </telerik:RadTab>
                                </Tabs>
                                <Tabs>
                                    <telerik:RadTab runat="server" Text="Graph" PageViewID="PageView2">
                                    </telerik:RadTab>
                                </Tabs>
                            </telerik:RadTabStrip>
                            <telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false">
                                <telerik:RadPageView runat="server" ID="PageView1">
                                    <telerik:RadGrid AllowSorting="True" runat="server" ID="grdReportDataGrid" AutoGenerateColumns="true"
                                        ShowFooter="true" EnableLinqExpressions="false">
                                    </telerik:RadGrid>
                                </telerik:RadPageView>
                                <telerik:RadPageView runat="server" ID="PageView2">
                                    <telerik:RadChart ID="RadChart2" Skin="DeepGray" runat="server" Height="400px" Width="1200px"
                                        AutoLayout="true" AutoTextWrap="true">
                                    </telerik:RadChart>
                                </telerik:RadPageView>
                            </telerik:RadMultiPage>
                        </asp:Panel>
                    </NestedViewTemplate>
                    <Columns>
                        <telerik:GridBoundColumn SortExpression="Name" HeaderText="Name" HeaderButtonType="TextButton"
                            DataField="Name" UniqueName="Name">
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadPageView>
    </telerik:RadMultiPage>


Code behind file:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExpandCollapseCommandName)
    {
        GridDataItem item = e.Item as GridDataItem;
        RadGrid grdReportDataGrid = (item.ChildItem as GridNestedViewItem).FindControl("grdReportDataGrid"as RadGrid;
        dynamic data = new[] {
        new { ID = 1, Name ="Naaaame1"},
        new { ID = 2, Name = "Naaaame2"},
        new { ID = 3, Name = "Naaaame3"},
         new { ID = 4, Name = "Naaaame4"},
        new { ID = 5, Name = "Namaaae5"},
        new { ID = 26, Name = "Naaaame26"}
    };
        grdReportDataGrid.DataSource = data;
        grdReportDataGrid.DataBind();
    }
}
  
  
protected void mainTab_TabClick(object sender, RadTabStripEventArgs e)
    {
        if (e.Tab.SelectedIndex == 1)
        {
            dynamic data = new[] {
        new { ID = 1, Name ="Name1"},
        new { ID = 2, Name = "Name2"},
        new { ID = 3, Name = "Name3"},
         new { ID = 4, Name = "Name4"},
        new { ID = 5, Name = "Name5"},
        new { ID = 26, Name = "Name26"}
    };
 
            RadGrid1.DataSource = data;
            RadGrid1.DataBind();
        }
 
    }

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 04 Jul 2013, 10:50 AM
Hi Srikar,

I guess you wan to keep the RadGrid1 expanded.Please try adding the following code snippet with your ItemCommand.

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExpandCollapseCommandName)
    {
        foreach (GridDataItem item1 in RadGrid1.MasterTableView.Items)
        {
            if (item1.Expanded == true)
            {
                item1.Expanded = true;
            }
        }
        GridDataItem item = e.Item as GridDataItem;
        RadGrid RadGrid3 = (item.ChildItem as GridNestedViewItem).FindControl("RadGrid3") as RadGrid;
        dynamic data = new[]
     {
        new { ID = 1, Name ="Naaaame1"},
        new { ID = 2, Name = "Naaaame2"},
        new { ID = 3, Name = "Naaaame3"},
        new { ID = 4, Name = "Naaaame4"},
        new { ID = 5, Name = "Namaaae5"}  
     };
        RadGrid3.DataSource = data;
        RadGrid3.DataBind();
    }
}

Thanks,
Princy
0
Srikar
Top achievements
Rank 1
answered on 04 Jul 2013, 11:58 AM

Hi Princy,

Let me explain the problem again as the give solution is not addressing my issue.

Steps to reproduce the issue:
1) use the the code "aspx" and ".cs" (posted in this thread)

1) Enable paging the grid  "grdReportDataGrid" and page size set page size is 3.

2) Please follow steps in attached document.

Thanks,
Srikar.


 
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 Jul 2013, 01:34 PM
Hello,

Please try with below code snippet.

protected void grdReportDataGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
   {
       GridNestedViewItem item = ((sender as RadGrid).NamingContainer as GridNestedViewItem); // Access Cuurernt Nesttedview
 
       GridDataItem pitem = item.ParentItem as GridDataItem; // access parent ROw
 
       dynamic data = new[] {
       new { ID = 1, Name ="Naaaame1"},
       new { ID = 2, Name = "Naaaame2"},
       new { ID = 3, Name = "Naaaame3"},
        new { ID = 4, Name = "Naaaame4"},
       new { ID = 5, Name = "Namaaae5"},
       new { ID = 26, Name = "Naaaame26"}
   };
 
       (sender as RadGrid).DataSource = data;
 
   }
 
 
   protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
   {
       if (e.CommandName == RadGrid.ExpandCollapseCommandName)
       {
           GridDataItem item = e.Item as GridDataItem;
           RadGrid grdReportDataGrid = (item.ChildItem as GridNestedViewItem).FindControl("grdReportDataGrid") as RadGrid;
 
           grdReportDataGrid.Rebind();
       }
   }
 
 
   protected void mainTab_TabClick(object sender, RadTabStripEventArgs e)
   {
 
       dynamic data = new[] {
       new { ID = 1, Name ="Name1"},
       new { ID = 2, Name = "Name2"},
       new { ID = 3, Name = "Name3"},
        new { ID = 4, Name = "Name4"},
       new { ID = 5, Name = "Name5"},
       new { ID = 26, Name = "Name26"}
   };
 
       RadGrid1.DataSource = data;
       RadGrid1.DataBind();
   }

<telerik:RadGrid AllowSorting="True" runat="server" ID="grdReportDataGrid" AutoGenerateColumns="true"
                                       ShowFooter="true" EnableLinqExpressions="false" AllowPaging="true" PageSize="3" OnNeedDataSource="grdReportDataGrid_NeedDataSource">
                                   </telerik:RadGrid>


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Srikar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Srikar
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or