【问题标题】:telerik nested grid issueTelerik 嵌套网格问题
【发布时间】:2010-03-17 14:56:43
【问题描述】:

1.这里我在父网格中有一个网格,嵌套网格中有一个链接按钮。

2.对于链接按钮我需要使用嵌套网格的item命令事件或者我也可以使用父网格的item命令。

3.问题是当我单击嵌套网格中的链接按钮时,不会为嵌套网格触发项目命令事件。但是在父网格的情况下它工作正常。

4.我已经尝试过处理程序和项目创建事件,也可以在代码后面或 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>

【问题讨论】:

标签: telerik telerik-grid


【解决方案1】:

没有看到你的一些代码,我不能确定这个问题出在哪里。我尝试的第一件事是类似于 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 层的层次结构,在短短几个小时内完成了一些代码,所有这些都只有 1 个 radgrid。

【讨论】:

  • 我听到了,我只是没有灵活性来改变这个特定项目的大部分方法
【解决方案2】:

您好,在嵌套视图中,您只能绑定一条记录,为了获得嵌套视图内的控件,我使用类似这样的东西。

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");
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-16
    • 1970-01-01
    • 1970-01-01
    • 2011-04-06
    相关资源
    最近更新 更多