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

[Solved] Expand hierarchy

1 Answer 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
El-Sheikh
Top achievements
Rank 1
El-Sheikh asked on 31 May 2009, 08:20 PM
Hi,
I've 3 levels hierarchy. all read from the same table as follow:

ID    RefID    ScheduleNo    CustPO    FabricIDSKU     MarkerID
1     Null        101                CO1            F1                    Null
2     Null        101                CO1            F2                    Null
3     Null        102                CO2            F1                    Null
4     Null        102                CO2            F2                    Null


I got the main Schedule from the table in level 1 where RefID IS NULL
Result:
Schedule
+ 101
+ 102

When expand the second level list all FabricIDSKU to be: where level2.ScheduleNo=Level1.ScheduleNo
Result:
    ID    RefID    ScheduleNo    FabricIDSKU    MarkerID
+ 1      null       101                 F1                    Null
+ 2      null       101                 F2                    Null


At this level I've inserted a select link, when i click i call a stored procedure from (RadGrid3_SelectedIndexChanged) and pass the "ID" of the selected item (example = 1), this procedure copy the same recored with new ID and in RefID "1" will be inserted.


Result:
    ID    RefID    Schedule    FabricIDSKU    MarkerID
    5       1             101            F1                    Null

then goto the third level and update the markerID. where Level3.RefID=parent (level2.ID)

I've two problems:
1- Level1 and level2 are expanding okay but i'm not able to expand level three.
2- After I've copy the recoerd through the stored procedure I run

 

Me.Marker_DS.DataBind()   
Me.RadGrid3.DataBind()  

 

 

 

After that the grid Collapse only level1 are displayed.

 

 

 

Code:
=====

 

<radG:RadGrid ID="RadGrid3" runat="server" AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="Schedules_DS" GridLines="None" Height="100%" Skin="Office2007" Width="100%" AllowFilteringByColumn="True" EnableAJAX="True">   
<PagerStyle Mode="NumericPages" />   
<MasterTableView AllowMultiColumnSorting="True" DataKeyNames="ScheduleNo" DataSourceID="Schedules_DS" Width="100%">   
<DetailTables>    
<radG:GridTableView runat="server" Caption="&lt;&lt;&lt;--- S C H E D U L E . . . . I T E M S ---&gt;&gt;&gt;" DataKeyNames="ID,ScheduleNo" DataSourceID="FabricSKU_DS" Width="100%">   
<ParentTableRelation>   
<radG:GridRelationFields DetailKeyField="ScheduleNo" MasterKeyField="ScheduleNo" /> </ParentTableRelation>   
<DetailTables>   
<radG:GridTableView runat="server" Caption="&lt;&lt;&lt;--- M A R K E R S . . . . D E T A I L S ---&gt;&gt;&gt;" DataKeyNames="RefID" DataSourceID="Marker_DS" Width="100%">   
<ParentTableRelation>   
<radG:GridRelationFields DetailKeyField="RefID" MasterKeyField="ID" /> </ParentTableRelation>  

 

 

 

DataSource are:
=============

<asp:SqlDataSource ID="Schedules_DS" runat="server" ConnectionString="<%$ ConnectionStrings:BMSPTConnS %>"   
SelectCommand="SELECT ScheduleNo, Date, CustPO FROM dbo.MarkerDetails GROUP BY RefID, ScheduleNo, TIEPO, CustPO HAVING (RefID IS NULL)"</asp:SqlDataSource> 
 
<asp:SqlDataSource ID="FabricSKU_DS" runat="server" ConnectionString="<%$ ConnectionStrings:BMSPTConnS %>"   
SelectCommand="SELECT ScheduleNo, Style, StyleName, ColorName, ID, FabricIDSKU FROM dbo.MarkerDetails WHERE (RefID IS NULL AND ScheduleNo=@ScheduleNo)">   
<SelectParameters>   
    <asp:SessionParameter Name="ScheduleNo" SessionField="ScheduleNo" Type="String" />   
</SelectParameters>   
</asp:SqlDataSource>   
 
<asp:SqlDataSource ID="Marker_DS" runat="server" ConnectionString="<%$ ConnectionStrings:BMSPTConnS %>"   
OldValuesParameterFormatString="original_{0}"   
SelectCommand="SELECT [ID],[RefID],[MarkerID],[ScheduleNo],[MOQty],[Style],[StyleName],[ColorName],[FabricIDSKU],[FabricWidth],[MarkerLength] FROM [MarkerDetails] WHERE [ScheduleNo] =@ScheduleNo"   
UpdateCommand="UPDATE MarkerDetails SET [MarkerID] = @MarkerID,[FabricWidth]=@FabricWidth,[MarkerLength]=@MarkerLength,[Layers]=@Layers WHERE ID = @original_ID">   
<SelectParameters>   
<asp:SessionParameter Name="ScheduleNo" SessionField="ScheduleNo" Type="decimal" />   
<asp:SessionParameter Name="ID" SessionField="ID" Type="decimal" />   
</SelectParameters>   
<UpdateParameters>   
<asp:Parameter Name="MarkerID" />   
<asp:Parameter Name="FabricWidth" />   
<asp:Parameter Name="MarkerLength" />   
<asp:Parameter Name="Layers" />   
<asp:Parameter Name="original_ID"/>   
</UpdateParameters>  

 

 

 

 

Code Behind:
===========

 

Protected Sub RadGrid3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid3.SelectedIndexChanged   
Dim OldDbCon As String = ConfigurationManager.ConnectionStrings("BMSPTConnS").ConnectionString   
Dim dbCon As SqlConnection   
dbCon = New SqlConnection(OldDbCon)   
Try   
Dim Command As New SqlClient.SqlCommand("usp_InsertMarkerDetails", dbCon)   
Command.CommandType = CommandType.StoredProcedure  
Dim parameterID As New SqlParameter("@ID", SqlDbType.BigInt, 11)   
parameterID.Value = RadGrid3.SelectedValue   
Command.Parameters.Add(parameterID)  
dbCon.Open()  
Command.ExecuteNonQuery()  
dbCon.Close()  
Me.Marker_DS.DataBind()   
Me.RadGrid3.DataBind()   
Finally   
dbCon.Dispose()   
End Try   
End Sub  

  

 

Any help will be appreciated.
Mohamed 

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 02 Jun 2009, 01:40 PM
Hello El-Sheikh,

Depending on the given information I suppose that the grid is not bound correctly when the levels are expanded. Note that to get working hierarchy functionality you need to use advanced data-binding.

I will suggest you examine this online demo and describe what the difference between your implementation and demo's one is.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
El-Sheikh
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or