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

nested radgrid will not page

3 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anna
Top achievements
Rank 1
Anna asked on 15 Jun 2012, 06:36 PM
I have a nested radgrid which does not page. All it does is collapse the grid when I try. I based it off of the grid/hierarchy with Templates demo from the telerik demo site and the code behind that it shows does not seem to be anything special but everything that I have tried has not worked. The nest radgrid that I am referencing is the one called RepresentedGrid.
If I remove the datasourceid and rely only on the needdatasource function being explicitly set up in the grid then I end up with an empty grid.
Part of the problem is the fact that even if I try to set up a page index changed function, the grid is never found so I end up with errors about instance not being set to an object.

   </telerik:RadAjaxManager>
   <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"
       AllowSorting="True" CellSpacing="0" GridLines="None" PageSize="20"
       ShowFooter="True" Width="979px" AutoGenerateColumns="false">
        
       <MasterTableView DataKeyNames="Fullname,FileAs, Email, Department, Company, BusinessPhone, BusinessFax, Website, Categories, OtherNotes, LinkedDocs, Represented" PageSize="20">
        <NestedViewTemplate>
        <asp:Panel runat="server" ID="InnerContainer" Visible="false" BackColor="AliceBlue">
        <telerik:RadTabStrip runat="server" ID="TabStip1" MultiPageID="Multipage1" SelectedIndex="0">
                       <Tabs>
                           <telerik:RadTab runat="server" Text="Contact Information" PageViewID="PageView1">
                           </telerik:RadTab>
                           <telerik:RadTab runat="server" Text="Distributors/Distributing" PageViewID="PageView2">
                           </telerik:RadTab>
                       </Tabs>
                   </telerik:RadTabStrip>
        <telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false">
        <telerik:RadPageView runat="server" ID="PageView1">
        <table >
        <tr><td>Business Fax:</td><td><%# Eval("BusinessFax")%></td></tr>
        <tr><td>Business Address:</td><td><%# addressFormat(Eval("BusinessAddress"))%></td></tr>
        <tr><td>Attached Documents:</td><td><%# documentShow(Eval("LinkedDocs"))%></td></tr>
        <%--<tr><td>Representing/Represented By:</td><td><%# cleanRepresented (Eval("Represented"))%></td></tr>--%>
        <tr><td>Other Notes:</td><td><%# Eval("OtherNotes")%></td></tr>
        </table>
        </telerik:RadPageView>
        <telerik:RadPageView runat="server" ID="RadPageView2">
 
<asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:SterlingConnection %>"
                               ProviderName="System.Data.SqlClient" SelectCommand='<%# vendorCrossReference(Eval("VendorID"))%>'
                               runat="server">
<telerik:RadGrid runat="server" ID="RepresentedGrid" DataSourceID="SqlDataSource3" ShowFooter="true" AllowPaging="True" EnableAJAX="True"
                                AllowSorting="true"  >
                                <PagerStyle Mode="Slider"></PagerStyle> 
                               <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true"
                                   DataKeyNames="VendorID, Fullname,FileAs, Email, Department, Company, BusinessPhone, BusinessFax, Website, Categories, OtherNotes, LinkedDocs, Represented"
                                   PageSize="20"  >
                                   
                                  <Columns>
                                  
                                    <telerik:GridBoundColumn SortExpression ="Company" HeaderText="Company" DataField ="Company" >
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn SortExpression ="Email" HeaderText="Email" DataField ="Email"  AllowFiltering="false" DataFormatString="<a href='mailto:{0}'>{0}</a>">
                                   </telerik:GridBoundColumn>
                                    
                                   <telerik:GridBoundColumn SortExpression ="Website" HeaderText="Website" AllowFiltering="false" DataField ="Website"  DataFormatString="<a href='{0}' target='_blank'>{0}</a>" >
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn SortExpression ="BusinessPhone" HeaderText="Business Phone" AllowFiltering="false" DataField ="BusinessPhone">
                                   </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression ="BusinessFax" HeaderText="Business Fax" DataField ="BusinessFax">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn SortExpression ="BusinessAddress" HeaderText="Business Address" DataField ="BusinessAddress">
                                   </telerik:GridBoundColumn>
 
 
                                  </Columns>
 
 
        </MasterTableView>
        </telerik:RadGrid>
 
        </telerik:RadPageView>
        </telerik:RadMultiPage>
         
        </asp:Panel>
        </NestedViewTemplate>   
        
       <Columns>
        
       <telerik:GridBoundColumn SortExpression ="Company" HeaderText="Company" DataField ="Company" >
        </telerik:GridBoundColumn>
       <telerik:GridBoundColumn SortExpression ="Email" HeaderText="Email" DataField ="Email" AllowFiltering="false" DataFormatString="<a href='mailto:{0}'>{0}</a>">
       </telerik:GridBoundColumn> 
       <telerik:GridBoundColumn SortExpression ="Website" HeaderText="Website" AllowFiltering="false" DataField ="Website" DataFormatString="<a href='{0}' target='_blank'>{0}</a>" >
       </telerik:GridBoundColumn>
       <telerik:GridBoundColumn SortExpression ="BusinessPhone" HeaderText="Business Phone" AllowFiltering="false" DataField ="BusinessPhone">
       </telerik:GridBoundColumn>
        <telerik:GridBoundColumn SortExpression ="Categories" HeaderText="Categories" DataField ="Categories">
       </telerik:GridBoundColumn>
 
 
       </Columns>

       Public Sub RepresentedGrid_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs)
           If Not e.IsFromDetailTable Then
 
               Dim dataSource As SqlDataSource = RadGrid1.MasterTableView.Items(0).ChildItem.FindControl("SqlDataSource3")
               Dim RepresentedGrid As RadGrid
               RepresentedGrid = RadGrid1.MasterTableView.Items(0).ChildItem.FindControl("RepresentedGrid")
               RepresentedGrid.DataSource = dataSource
 
            
           End If
       End Sub
 
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemCreated
           If TypeOf e.Item Is GridNestedViewItem Then
           Dim typeContent = DirectCast(e.Item.FindControl("RepresentedGrid"), RadGrid)
           AddHandler typeContent.NeedDataSource, AddressOf Me.RepresentedGrid_NeedDataSource
           End If
End Sub

3 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 20 Jun 2012, 08:44 AM
Hello Anna,

Do you use the latest version of the controls? EnableAJAX="True" does not longer enable ajax for the grid, this property is legacy from the classic rad controls.
If you want to ajaxify it properly, then find the RepresentedGrid during the ItemCreated event of the parent grid, and then add dynamically settings to the AjaxManager in order to ajaxify the inner grid.

Also the InnerContainer should be visible in the declaration (you could set visible=false later in the ItemDataBound), otherwise its viewstate will not be loaded properly. So the paging in the inner grid will not work.

All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Anna
Top achievements
Rank 1
answered on 02 Jul 2012, 07:04 PM
I am guessing that my problem is that the grid I am trying to work with is within a nestedviewtemplate and I am not sure how to access controls that are with in a nestedviewtemplate.
I believe that I am using v. 2011.271240 of the ajax version of the radcontrols.
0
Anna
Top achievements
Rank 1
answered on 03 Jul 2012, 09:11 PM
Tags
Grid
Asked by
Anna
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Anna
Top achievements
Rank 1
Share this question
or