2010-03-17 120 views
1

1.我在父網格中有一個網格,嵌套網格中有一個鏈接按鈕。telerik嵌套網格問題

2.對於鏈接按鈕,我需要使用嵌套網格的item命令事件,或者我也可以使用父網格的item命令。

3.問題是,當我點擊嵌套網格內的鏈接按鈕,然後項目命令事件不會被觸發的嵌套網格。但在母網格的情況下它的工作正常。

4.我已經嘗試過處理程序和item創建的事件,以便在代碼後面或aspx中使用處理程序。但沒有任何幫助讓我爲嵌套網格命令事件命中。

5.以前在中繼器的情況下,有一個項目命令處理所有的網格。我已經爲孩子和家長嘗試了不同的項目命令事件,但它也沒有工作。

編輯:這裏是一個代碼示例

Public Sub grd_ItemCommand(ByVal source As Object, _ 
               ByVal e As nsTelerik.GridCommandEventArgs) _ 
               Handles grdCollClaimLevel.ItemCommand, grdCollLineLevel.ItemCommand, _ 
               grdCollLineValues.ItemCommand, grdCollPartLevel.ItemCommand, _ 
               grdPTNClaimLevel.ItemCommand, _ 
               grdPTNLineLevel.ItemCommand, grdPTNLineValues.ItemCommand 


     Dim uicCharMain As nsPTNWebContext.CharMainUIC 
     Dim uicCollDetl As nsPTNWebContext.CollDetlUIC 
     Dim uicPTNItem As nsPTNWebContext.PatternItemUIC 

     Try 

      Select Case e.CommandName 
       Case c_sBtnChar 

        uicCharMain = New nsPTNWebContext.CharMainUIC() 

        With uicCharMain 
         .CharID = CStr(e.CommandArgument) 
         .Busns_Event_Cd = m_uicRsltMatc.BusEvent 
         .PTN_LOB_Cd = m_uicRsltMatc.LOB 
         .UserID = m_uicRsltMatc.UserID 
         .ModePTN = m_uicRsltMatc.ModePattern 
         .ModeChar = m_uicRsltMatc.ModeChar 
         .ModeColl = m_uicRsltMatc.ModeColl 
         .ModeRept = m_uicRsltMatc.ModeRept 
         .PageMode = nsPTNWebContext.CharMainUIC.enPageMode.View 
         .TabMode = m_uicRsltMatc.TabMode 
        End With 

        Me.PageState.Save() 
        Me.Navigation.AddMe(c_sCharMain) 
        Me.Navigation.Transfer(uicCharMain) 

       Case c_sBtnColl 

        uicCollDetl = New nsPTNWebContext.CollDetlUIC(_ 
         CStr(e.CommandArgument), _ 
         m_uicRsltMatc.BusEvent, _ 
         m_uicRsltMatc.LOB) 

        With uicCollDetl 
         .UserID = m_uicRsltMatc.UserID 
         .ModeColl = m_uicRsltMatc.ModeColl 
         .PageMode = nsPTNWebContext.CollDetlUIC.enPageMode.View 

         .ModePTN = m_uicRsltMatc.ModePattern 
         .ModeChar = m_uicRsltMatc.ModeChar 
         .ModeRept = m_uicRsltMatc.ModeRept 
         .BusEvent = m_uicRsltMatc.BusEvent 
         .LOB = m_uicRsltMatc.LOB 
         .TabMode = m_uicRsltMatc.TabMode 
        End With 

        Me.PageState.Save() 
        Me.Navigation.AddMe(c_sCollDetails) 
        Me.Navigation.Transfer(uicCollDetl) 

       Case c_sBtnPattern 

        uicPTNItem = New nsPTNWebContext.PatternItemUIC(CStr(e.CommandArgument)) 

        With uicPTNItem 
         .BusEvent = m_uicRsltMatc.BusEvent 
         .LOB = m_uicRsltMatc.LOB 
         .UserID = m_uicRsltMatc.UserID 
         .ModeChar = m_uicRsltMatc.ModeChar 
         .ModeColl = m_uicRsltMatc.ModeColl 
         .ModePattern = m_uicRsltMatc.ModePattern 
         .ModeRept = m_uicRsltMatc.ModeRept 
         .CharID = m_uicRsltMatc.CharID 
         .CollID = m_uicRsltMatc.CollID 
         .PageMode = nsPTNWebContext.PatternItemUIC.enPageMode.View 
         .TabMode = m_uicRsltMatc.TabMode 
        End With 

        Me.PageState.Save() 
        Me.Navigation.AddMe(c_sPatternItem) 
        Me.Navigation.Transfer(uicPTNItem) 

      End Select 

     Finally 
      Cleanup(uicCharMain) 
      uicCharMain = Nothing 
      Cleanup(uicCollDetl) 
      uicCollDetl = Nothing 
      Cleanup(uicPTNItem) 
      uicPTNItem = Nothing 

     End Try 
    End Sub 

而這裏的標記

 <tel:radgrid runat="server" id="grdPTNPartLevel" width="100%" autogeneratecolumns="false" 
      horizontalalign="Justify"> 
      <mastertableview width="100%"> 
       <NestedViewTemplate> 
        <tel:RadGrid runat="server" ID="grdPTNPartValues" Width="100%" AutoGenerateColumns="false" 
         HorizontalAlign="Justify" OnItemDataBound="grdPTNPartValues_ItemDataBound"> 
        </tel:RadGrid> 
        <tel:RadGrid runat="server" ID="grdPTNLineLevel" Width="100%" AutoGenerateColumns="false" 
         HorizontalAlign="Justify" OnItemDataBound="grdPTNLineLevel_ItemDataBound" OnItemCommand="grd_ItemCommand"> 
         <MasterTableView Width="100%"> 
          <NestedViewTemplate> 
           <tel:RadGrid runat="server" ID="grdPTNLineValues" Width="100%" AutoGenerateColumns="false" 
            HorizontalAlign="Justify" OnItemDataBound="grdPTNLineValues_ItemDataBound" OnItemCommand="grd_ItemCommand"> 
           </tel:RadGrid> 
          </NestedViewTemplate> 
         </MasterTableView> 
        </tel:RadGrid> 
       </NestedViewTemplate> 
      </mastertableview> 
     </tel:radgrid> 
+0

有些代碼可以幫助說明問題。你能發佈整個網格的標記嗎? – Aaron 2010-03-17 15:01:42

+0

謝謝,我剛剛發佈的標記 – Jeff 2010-03-17 16:13:56

+0

也此示例http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx可以幫助 – dankyy1 2010-09-16 08:09:24

回答

0

沒有看到你的一些代碼,我不能在這個地方的問題在於相當肯定。我嘗試的第一件事情是類似於telerik在其API here中的內容。在對命令項進行任何操作之前,您需要確保使用正確的OwnerTable。使用這樣的東西,確定該項目是爲正確的表,然後你應該有權訪問它。

//identify to which table belongs the currently bound item 
     if (e.Item.OwnerTableView.Name == "MyUniqueTableName") 
     { 
     //process requested operations 
     } 

編輯

我看到你想要做什麼。我想你可能會以錯誤的方式去做。看看telerik demo page here上的層次結構部分。它的內容非常豐富,我有一個4層的層次結構,在短短几個小時內完成了一些代碼,所有代碼都只有一個radgrid。

+0

我聽到雅,我只是不可以靈活地改變這個特定項目的大部分方法 – Jeff 2010-03-17 16:30:42

0

你好,在嵌套視圖中,只有你可以綁定一條記錄,爲了得到嵌套視圖內的控件,我使用了類似這樣的東西。

protected void gvwData_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
{ 
    if (e.Item.ItemType == GridItemType.NestedView) 
    { 
     GridDataItem item = e.Item as GridDataItem; 
     HtmlGenericControl InfoDvi= (HtmlGenericControl)e.Item.FindControl("DivWithServerSideTagName"); 
    } 
}