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

Sorting/Filtering Not working with Hierarchy using NestedViewTemplate which loads data via ObjectDataSource

6 Answers 251 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sal
Top achievements
Rank 1
Sal asked on 29 Jul 2011, 05:55 PM

I have a grid with nested views via tempates.  The tamplate retrieves data though an ObjectDataSource that gets it form a Webservice.
Now, when I expand any element in the hierarchy it works perfectly, however, if I try to sort or filter any column from the Mater Table, I get an exception:

Error: Sys.WebForms.PageRequestManagerServerErrorException: The DataSourceID of 'FormView' must be the ID of a control of type IDataSource.  A control with ID 'ObjectDataSource' could not be found.

I have tried adding the same ObjectDataSource after the grid definition but it does work (not exception thrown) for sorting/filtering of the Master Table but if I try to expand any of the nested views, it simply does not show any data. However, if right before I try sorting/filtering the master table (right after I load the gid for the first time) I expand any of the nested views, they do get the data. It is only after I sort/filter that they don't. 

The following is the code for the radGrid that I currently have, which is the one that forces the exception to be thrown:

<telerik:RadGrid ID="OrbitRadGrid" runat="server" AllowFilteringByColumn="True" AllowSorting="True" VirtualItemCount="50000" 
    GridLines="None" AllowPaging="true" PageSize="20" AllowCustomPaging="true" ShowGroupPanel="false" EnableLinqExpressions="false" 
    OnNeedDataSource="OrbitRadGrid_NeedDataSource" OnSortCommand="OrbitRadGrid_SortCommand"
    Skin="WebBlue" >
    <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="False" ReorderColumnsOnClient="True">
        <Scrolling AllowScroll="True" EnableVirtualScrollPaging="True" UseStaticHeaders="True" SaveScrollPosition="True" />
        <Resizing AllowColumnResize="True" />
    </ClientSettings>
    <MasterTableView DataKeyNames="Item_Name, Source_Name" AutoGenerateColumns="False" AllowNaturalSort="false" >
          
        <Columns>
            <telerik:GridBoundColumn DataField="Item_Name" HeaderText="Item Name" 
                ReadOnly="True" SortExpression="Item_Name" UniqueName="Item_Name" HeaderStyle-Width="220px">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Source_Name" HeaderText="Item Source" ReadOnly="True" 
                SortExpression="Source_Name" UniqueName="Source_Name" HeaderStyle-Width="220px">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ItemType_Name" HeaderText="Item Type" ReadOnly="True" 
                SortExpression="ItemType_Name" UniqueName="ItemType_Name" HeaderStyle-Width="115px">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Team_Name" HeaderText="Item Team" ReadOnly="True" 
                SortExpression="Team_Name" UniqueName="Team_Name" HeaderStyle-Width="115px">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="IsTestItem" HeaderText="Test" ReadOnly="True" 
                UniqueName="IsTestItem"  AllowFiltering="false" HeaderStyle-Width="50px">
            </telerik:GridBoundColumn>
              
            <telerik:GridBoundColumn DataField="IsItemOnHold" HeaderText="On Hold" ReadOnly="True" 
                UniqueName="IsItemOnHold"  AllowFiltering="false" HeaderStyle-Width="62px">
            </telerik:GridBoundColumn>
             
        </Columns>
          
        <NestedViewTemplate>
            <asp:Label ID="ItemName"   Text='<%# Eval("Item_Name") %>'   Visible="false" runat="server" />
            <asp:Label ID="ItemSource" Text='<%# Eval("Source_Name") %>' Visible="false" runat="server" />
            <asp:FormView ID="FormView" runat="server" DataSourceID="ObjectDataSource">
                <ItemTemplate>
                    <asp:Panel ID="NestedViewPanel" runat="server" CssClass="viewWrap" Width="1000px">
                        <telerik:RadTabStrip runat="server" ID="TabStip" MultiPageID="Multipage" SelectedIndex="0" Skin="WebBlue">
                            <Tabs>
                                <telerik:RadTab runat="server" Text="General" PageViewID="General"/>
                                <telerik:RadTab runat="server" Text="Status" PageViewID="Status"/>
                                <telerik:RadTab runat="server" Text="Coverage" PageViewID="Coverage"/>
                                <telerik:RadTab runat="server" Text="Rejection" PageViewID="Rejection"/>
                            </Tabs>
                        </telerik:RadTabStrip>
                        <telerik:RadMultiPage runat="server" ID="Multipage" SelectedIndex="0" RenderSelectedPageOnly="false" Height="90px">
                     
                            <telerik:RadPageView runat="server" ID="Genearal">
                                <table>
                                    <tr>
                                        <td><b>   Name:</b></td>
                                        <td><asp:Label id="Label0" runat="server" Text='<%# Eval("ItemName") %>' /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Source:</b></td>
                                        <td><asp:Label id="Label1" runat="server" Text='<%# Eval("ItemSource") %>' /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Type:</b></td>
                                        <td><asp:Label id="Label2" runat="server" Text='<%# Eval("ItemType") %>' /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Acq. Number:</b></td>
                                        <td><asp:Label id="Label3" runat="server" Text='<%# Eval("ItemAcqNumber") %>' /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Description:</b></td>
                                        <td><asp:Label id="Label4" runat="server" Text='<%# Eval("ItemDescription") %>' /></td>
                                    </tr>                                       
                                </table
                            </telerik:RadPageView>
                              
                            <telerik:RadPageView runat="server" ID="Status">
                                <table>
                                    <tr>
                                        <td><b>   Status:</b></td>
                                        <td><asp:Label id="Label6" runat="server" Text='<%# Eval("ItemStatus") %>' /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Date:</b></td>
                                        <td><asp:Label id="Label7" runat="server" Text='<%# Eval("ItemStatusDate") %>' /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Detail:</b></td>
                                        <td><asp:Label id="Label8" runat="server" Text='<%# Eval("ItemStatusDetail") %>' /></td>
                                    </tr>
                                </table>                   
                            </telerik:RadPageView>
                              
                            <telerik:RadPageView runat="server" ID="Coverage">
                                <table>
                                    <tr>
                                        <td><b>   Coverage 1:</b></td>
                                        <td><asp:Label id="Label9" runat="server" Text='<%# Eval("ItemCoverage1") %>' /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Coverage 2:</b></td>
                                        <td><asp:Label id="Label10" runat="server" Text='<%# Eval("ItemCoverage2") %>' /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Coverage 2 Type:</b></td>
                                        <td><asp:Label id="Label11" runat="server" Text='<%# Eval("ItemCoverage3Description") %>' /></td>
                                    </tr>
                                </table>
                            </telerik:RadPageView>
                            <telerik:RadPageView runat="server" ID="Rejection">
                                <table>
                                    <tr>
                                        <td><b>   Report Delivery:</b></td>
                                        <td><asp:Label id="Label12" runat="server" Text="Email" /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Indicator:</b></td>
                                        <td><asp:Label id="Label13" runat="server" Text="abc" /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Email Recipients:</b></td>
                                        <td><asp:Label id="Label14" runat="server" Text="joe@mail.com|jane@mail.com" /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   Node Id:</b></td>
                                        <td><asp:Label id="Label15" runat="server" Text="1234" /></td>
                                    </tr>
                                    <tr>
                                        <td><b>   FTP Name:</b></td>
                                        <td><asp:Label id="Label16" runat="server" Text="ftp://server.com" /></td>
                                    </tr>
                                </table>
                            </telerik:RadPageView>
                        </telerik:RadMultiPage>
                    </asp:Panel>
                </ItemTemplate>
            </asp:FormView>
            <asp:ObjectDataSource runat="server" ID="ObjectDataSource" SelectMethod="Get" TypeName="Orbit3UI.Model.MasterItemDetailsDataSource">
                <SelectParameters>
                    <asp:ControlParameter ControlID="ItemName" Name="ItemName" PropertyName="Text" />
                    <asp:ControlParameter ControlID="ItemSource" Name="ItemSource" PropertyName="Text" />
                </SelectParameters>
            </asp:ObjectDataSource>
        </NestedViewTemplate>
    </MasterTableView>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
</telerik:RadGrid>

So what can I do in order to have this work for both sorting/filtering as well as hierarchy expansion? 

BTW, I do my own sorting/filtering as well as paging since I cannot load all the records from the database at once. 

I am wondering if by intercepting an event and doing something I can stop the grid from trying to interact with the FormView in the NestedTemplateView at all since all I want is to sort the Master Table! . 

Thanks. 

Sal
  

6 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 01 Aug 2011, 12:56 PM
Hello Sal,

Please try placing the ObjectDataSource outside of the NestedViewTemplate and the grid itself and it should work as expected.

Best wishes,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Sal
Top achievements
Rank 1
answered on 01 Aug 2011, 02:46 PM
Hi Pavlina,

As I explained in parragraph 3 in my original post, no that does not work, here is the original:

I have tried adding the same ObjectDataSource after the grid definition but it does work (not exception thrown) for sorting/filtering of the Master Table but if I try to expand any of the nested views, it simply does not show any data. However, if right before I try sorting/filtering the master table (right after I load the gid for the first time) I expand any of the nested views, they do get the data. It is only after I sort/filter that they don't. 

So basically, it works for filter/sort but if I perform any of these operations, it will then not show any detail data in the expanded views, however, if I expand any view first, it does work until I decide to sort/filter, in which case, the first expanded view will have no data at all.

Now, if you notice, the ObjectDataSource uses hidden labels, which ar part of the template, in order to get the keys for the expanded views. If these are not in the template, then I cannot pass the information. THIS, I believe, is the resason why putting the datasource out of the grid causes it to fail. Note that I am forced to use this workarround becuase of a weakness in the radGrid when working with objectDataSources which causes it not to display expanded views correctly (i.e. it seems not to be able to get the NestedViewSettings correctly, except if working with SqlDataSources).

Thanks

Sal
0
Sal
Top achievements
Rank 1
answered on 03 Aug 2011, 12:42 PM
I guess not even you guys at Telerik have a clue?
It is hard to believe that nobody has encountered this issue before. The problem is simple, want to be able to sort/filter the master table and view details in nested templated views.
Problem is with the ObjectDataSource not updating the nested records correctly, as I detailed in my other post so I used a workaround publised by someone (use hidden labels to pass the variable names tothe datasource). Perhaps an issue with the viewstate? It would help if you could at least share how the view state for nested items is persisted so I can implement it myself or something.
I would hate to have to revet to a normal Grid and implement all functionality by hand. We just bought the whole Telerik pack and thought the radGrid would help us by not having to write much code.
Anyway, hopefully I'll get an answer before having to try some more extreme solutions (we are even trying with silverlight's radGridView! but this does not incorporate the same functionality).

Sal
0
Pavlina
Telerik team
answered on 04 Aug 2011, 03:01 PM
Hello Sal,

In order to properly assist you, I would suggest that you open a formal support ticket, and send us a small working project, showing the issue that you described. We will advise you further, as soon as we review it.

Best wishes,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Sal
Top achievements
Rank 1
answered on 04 Aug 2011, 04:00 PM
I have created support ticket # 450768 Under "Damian", who is the person who acquired the software licenses for my team. I hope it won't make a difference. 

Sal.  
0
Sal
Top achievements
Rank 1
answered on 08 Aug 2011, 02:15 PM
Here is the answer:

Move the datasource before the formview, see the following for the details:

http://www.telerik.com/community/forums/aspnet-ajax/grid/master-detail-hierarchy-binding-via-objectdatasource.aspx

Sal
Tags
Grid
Asked by
Sal
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Sal
Top achievements
Rank 1
Sal
Top achievements
Rank 1
Share this question
or