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

Hierarchy - Add New Record doesn't show for child

1 Answer 23 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 2
Elliott asked on 23 Aug 2010, 08:32 PM
I'm trying to create a RadGrid - and only to parent columns show Add New Record
I put a CommandItemDisplay in the GridTableView, set up the right ParentTableRelations
Protected Sub rgSpiffDetail_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgSpiffDetail.NeedDataSource
    Dim VendorID As Integer = 0
    Dim ds As DataSet = Nothing
    Dim dt As DataTable = Nothing
 
    If rcbVendors.SelectedValue = String.Empty Then
        VendorID = Quicksilver_VendorID
    Else
        VendorID = rcbVendors.SelectedValue
    End If
    Dim ws As New CommonFunctions
    If e Is Nothing Then
    ElseIf e.IsFromDetailTable Then
        Exit Sub
    End If
    ds = ws.GetSpiffs(VendorID)
    If ds.Tables.Count > 0 Then
        dt = ds.Tables(0)
    End If
    rgSpiffDetail.DataSource = dt
End Sub
 
Protected Sub rgSpiffDetail_DetailTableDataBind(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles rgSpiffDetail.DetailTableDataBind
    Dim gdItem As GridDataItem = Nothing
    Dim SpiffID As Integer = 0
    Dim ds As DataSet = Nothing
    Dim dt As DataTable = Nothing
 
    gdItem = CType(e.DetailTableView.ParentItem, GridDataItem)
    SpiffID = CInt(gdItem.GetDataKeyValue("SpiffID"))
    Dim ws As New CommonFunctions
    ds = ws.GetItemsforSpiff(SpiffID)
End Sub
 
Protected Sub rcbVendors_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles rcbVendors.SelectedIndexChanged
    Dim ea As Telerik.Web.UI.GridNeedDataSourceEventArgs = Nothing
    rgSpiffDetail.Rebind()
End Sub
and the code behind

<telerik:RadGrid ID="rgSpiffDetail" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" Width="95%" runat="server" >
<MasterTableView DataKeyNames="SpiffID" CommandItemDisplay="Top" Width="100%">
    <DetailTables>
        <telerik:GridTableView Name="Items" DataKeyNames="ItemID" CommandItemDisplay="Bottom" Width="100%">
        <ParentTableRelation>
            <telerik:GridRelationFields MasterKeyField="SpiffID" DetailKeyField="SpiffID" />
        </ParentTableRelation>
        <Columns>
            <telerik:GridBoundColumn UniqueName="SpiffID" DataField="SpiffID" HeaderText="SpiffID" />
            <telerik:GridBoundColumn UniqueName="ItemID" DataField="ItemID" HeaderText="ItemID" />
            <telerik:GridBoundColumn UniqueName="KMSPartNo" DataField="KMSPartNo" HeaderText="KMS Part Number" />
            <telerik:GridBoundColumn UniqueName="LNSPartNo" DataField="LNSPartNo" HeaderText="LNS Part Number" />
            <telerik:GridBoundColumn UniqueName="Description" DataField="Description" HeaderText="Description" />
            <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" Text="Delete" />
        </Columns>
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
            <table border="0" cellpadding="2" cellspacing="2">
            <tr>
            <td>Items</td>
            <td>
                <telerik:RadComboBox ID="rcbItems" AutoPostBack="true" runat="server" />
            </td>
            </tr>
            </table>
            </FormTemplate>
        </EditFormSettings>
        </telerik:GridTableView>
    </DetailTables>
    <Columns>
        <telerik:GridButtonColumn UniqueName="Edit" Text="Edit" CommandName="Edit" />
        <telerik:GridBoundColumn UniqueName="SpiffID" DataField="SpiffID" HeaderText="SpiffID" ReadOnly="True" />
        <telerik:GridBoundColumn UniqueName="Seq" DataField="Seq" HeaderText="seq" />               
        <telerik:GridTemplateColumn UniqueName="CashBack" HeaderText="CashBack" >
            <ItemTemplate>
                <asp:Label ID="lblCashBack" Text='<%# Bind("CashBack") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbCashBack" text='<%# Eval("CashBack") %>' runat="server">
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn>
            <ItemTemplate>
                <asp:Label ID="lblCaseDollarItem" Text='<%# Bind("CaseDollarItemDesc") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:RadioButtonList ID="rblCaseDollarItem" DataValueField="CaseDollarItem" runat="server">
                    <asp:ListItem Value="C" Text="Case" />
                    <asp:ListItem Value="D" Text="Dollar" />
                    <asp:ListItem Value="I" Text="Item" />
                </asp:RadioButtonList>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridCheckBoxColumn UniqueName="AllorByItem" DataField="AllOrByItem" HeaderText="AllItems" />
        <telerik:GridTemplateColumn UniqueName="QtytoOrder" HeaderText="Qty to Order">
            <ItemTemplate>
                <asp:Label ID="lblQtytoOrder" Text='<%# Eval("QtytoOrder") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbQtytoOrder" runat="server" />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="DollartoOrder" HeaderText="$ to Order">
            <ItemTemplate>
                <asp:Label ID="lblDollartoOrder" Text='<%# Eval("DollartoOrder") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbDollartoOrder" runat="server" >
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="MinQty" HeaderText="Min Qty">
            <ItemTemplate>
                <asp:Label ID="lblMinQty" Text='<%# Eval("MinQty") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbMinQty" runat="server" />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="MinDollar" HeaderText="Min Dollar">
            <ItemTemplate>
                <asp:Label ID="lblMinDollar" Text='<%# Eval("MinDollar") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbMinDollar" runat="server" >
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn UniqueName="SpiffDescription" DataField="SpiffDescription" HeaderText="Description" >
            <ItemStyle Width="200px" />
        </telerik:GridBoundColumn>
        <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"/>
    </Columns>
</MasterTableView>
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 24 Aug 2010, 03:15 PM
Hi Marianne,

Please examine our online example and see what is the difference in your case.
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx

Sincerely yours,
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
Tags
Grid
Asked by
Elliott
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Share this question
or