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

radGrid inside nestedviewTemplate problem

5 Answers 267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
duheng
Top achievements
Rank 1
duheng asked on 11 May 2010, 07:43 PM
Hi,

I have two radGrids, one as the upper level one, one inside the nestedViewTemplate. When I expand the row of the upper level grid, the inner Grid will be shown up. The data shown in the inner table is dependent on some id.  I followed the Hierarchy with Templates demo on telerik.com. However, I got the following problem:
1. When I click one row, I got the right inner Grid. When I click another row, the first inner Grid will be updated with the seconde inner Grid information even though they should be different. When I click a third row, all three inner grid will have the third inner grid information.
2. When I collapse the third row, the two inner Grids of expanded rows will have the second row information. 

In all, the inner grid is always upated with the latest expanded row. I followed the demo, don't know why i have such strange problem. Can u help me out?

Here is the code: 
<Telerik:RadGrid Height ="612"  ID="Results"  HorizontalAlign="Center" runat="server" AllowPaging="True" AllowSorting="True" 
                    Font-Names="Tahoma"  OnItemCommand="Results_OnItemCommand"  GridLines="None" Skin="Office2007" 
                    OnPreRender="Results_PreRender" OnExcelExportCellFormatting="dgResults_ExcelExportCellFormatting" OnPageSizeChanged ="dgResults_pageSizeChanged">  
                                       
                    <MasterTableView Width ="98.5%" TableLayout="auto" GroupLoadMode ="client" DataKeyNames ="General ID"  >   
                    <Columns> 
</Columns> 
<NestedViewSettings DataSourceID="AccessDataSource1">  
                    <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="GeneralID" MasterKeyField="General ID" /> 
                        </ParentTableRelation>                                                
                   </NestedViewSettings> 
                    
                   <NestedViewTemplate> 
                   <asp:Panel runat="server" ID="InnerContainer" CssClass ="viewWrap" Visible="false">   
<telerik:radGrid HorizontalAlign ="center" ID ="dgResutls_inner"  runat ="server" OnNeedDataSource ="inner_needDataSource" AllowPaging="True" AllowSorting="True" Skin="Office2007" >     
                     <AlternatingItemStyle  Font-Size="8pt" CssClass="MyAlternatingClass" wrap="False"/>  
                    <ItemStyle Font-Names="Tahoma" Font-Size="8pt" CssClass ="MyClass"  wrap="False" /> 
                    <HeaderStyle Font-Bold="True" Font-Size="9pt" ForeColor="Black" Wrap="False" HorizontalAlign="Center" /> 
                    <ClientSettings > 
                    <Selecting AllowRowSelect ="true" /> 
                     
                    </ClientSettings> 
                    <MasterTableView TableLayout ="auto" > 
                    </MasterTableView> 
                              
                    </telerik:radGrid> 
                     
                     
                 
                   </asp:Panel> 
                   </NestedViewTemplate> 
 </MasterTableView> 
</Telerik:RadGrid> 
 
 <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetResults" UpdateMethod="GetResults" InsertMethod="GetResults" TypeName="iFindSearchDB"></asp:ObjectDataSource> 
   <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="stage.mdb" SelectCommand="SELECT * FROM [stage] where GeneralID=@GeneralID">  
      <SelectParameters> 
                <asp:SessionParameter Name="GeneralID" SessionField="GeneralID" Type="Int32" /> 
            </SelectParameters> 
 
    </asp:AccessDataSource>  
 BTW, i will store the generalID in a session variable every time I click the row and use session parameter to databind the innerGrid.

5 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 13 May 2010, 11:52 PM
I have the exact same problem and am searching for answers. It seems a RadGrid inside a NestedViewTemplate is not calling the NeedDataSource function on creation, but will call it after the next postback.
0
Pavlina
Telerik team
answered on 14 May 2010, 09:49 AM
Hello,

In order to achieve your goal, I suggest that you bind both grids through the NeedDataSource event. For the outer grid there is nothing specific, you can do it as for a regular grid. And in the inner grid NeedDataSource event, you can get reference to the outer grid expanded item, e.g. the parent item. Thus you can get a data field value of the expanded item and use it for retrieving the inner grid data source.

However, I am sending you a simple working project which handles the desired functionality. Please
give it a try and let me know if it works as expected.

I hope this helps.

Greetings,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
duheng
Top achievements
Rank 1
answered on 17 May 2010, 09:40 PM
Hi Pavlina,

Thanks for your project.
I bind the inner grid through NeedDataSource and set the DataKeyNames as the dependency column in the out grid, rebind the inner grid in the itemCommand event (expandCollapse). It worked. 

Best regards,
Heng  
0
Smiely
Top achievements
Rank 1
answered on 06 Apr 2011, 06:22 PM
Hi,

I have a repeater inside RadGrid and it's acting this way. How do I put needdatasource on repeater ?

Please help
Thanks
Smiely
0
Pavlina
Telerik team
answered on 11 Apr 2011, 03:55 PM
Hello Smiely,

In order to properly assist you, it will be best if you can send us a simple running project (incl. CSS, images, skins, DB backup if needed and so on) demonstrating the problem (and step-by-step instructions on doing so). In that way we can reproduce and pinpoint the problems you're facing on our side, understand the logic of your application and provide a solution.

Kind regards,
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.

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