2011-11-08 71 views
0

我有一個RadGrid,並在RadGrid1.MasterTableView.NestedViewTemplate裏面有另一個RadGrid。外部RadGrid是RadGrid1,內部RadGrid是RadGrid2。 RadGrids都是從後面的代碼創建的。我定義的關係,就像這樣:Telerik Hierarchical RadGrid NeedDatasource:如何引用ParentID?

RadGrid1.MasterTableView.NestedViewSettings.ParentTableRelation.Add(New Telerik.Web.UI.GridRelationFields() With {.DetailKeyField = "ID", .MasterKeyField = "ID"}) 

我的問題是:

我有內部radgrid控件一個NeedDatasource事件,我想通過父行的ID的ID進行過濾。我怎樣才能做到這一點?

回答

0

問題解決。我已經爲RadGrid2.NeedDatasource添加了以下代理的處理程序:

Public Sub RadGrid2_NeedDatasource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) 
     Dim innerGrid As RadGrid = CType(source, RadGrid) 
     Dim nestedItem As GridNestedViewItem = CType(innerGrid.NamingContainer, GridNestedViewItem) 
(nesteditem.ParentItem)).GetDataKeyValue("ID")); 
     Dim ShiftID = CType(nestedItem.ParentItem, GridDataItem).GetDataKeyValue("ID") 
     '... 
    End Sub