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

ParentId not set

2 Answers 72 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
PPaulsen
Top achievements
Rank 1
PPaulsen asked on 04 Nov 2014, 01:18 PM
Hello,

I'm urgently trying to bind a RadTreeList to an EntityDataSource.

    <telerik:RadTreeList runat="server" DataKeyNames="Id" ParentDataKeyNames="TreeElementId" DataSourceID="MediaAssetGroups" AutoGenerateColumns="false" ID="rtlCategories" OnItemInserted="rtlCategories_ItemInserted">
        <Columns>
            <telerik:TreeListBoundColumn DataField="Id" HeaderText="ID" ReadOnly="false"
                UniqueName="EmployeeID" HeaderStyle-Width="60px" ForceExtractValue="Always" Visible="false">
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="Name" HeaderText="Name" ReadOnly="false"
                Visible="true">
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="Description" HeaderText="Beschreibung" ReadOnly="false"
                Visible="true">
            </telerik:TreeListBoundColumn>
            <telerik:TreeListCheckBoxColumn DataField="IsGlobalCategory" DefaultInsertValue="true" HeaderText="Globale Kategorie">
            </telerik:TreeListCheckBoxColumn>
            <telerik:TreeListCheckBoxColumn DataField="ContainsGlobalContent" DefaultInsertValue="false" HeaderText="Globaler Inhalt" Visible="true">
            </telerik:TreeListCheckBoxColumn>
            <telerik:TreeListCheckBoxColumn DataField="IsActive" DefaultInsertValue="true" HeaderText="Aktiv">
            </telerik:TreeListCheckBoxColumn>
            <telerik:TreeListCheckBoxColumn DataField="IsDeleted" DefaultInsertValue="false" HeaderText="Gelöscht" Visible="false">
            </telerik:TreeListCheckBoxColumn>
            <telerik:TreeListBoundColumn DataField="TreeElementId" ReadOnly="false">
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="UserId" HeaderText="Creator" ReadOnly="false"
                Visible="false" />

            <telerik:TreeListDateTimeColumn DataField="CreationDate" HeaderText="Erstelldatum" ReadOnly="false" Visible="false"></telerik:TreeListDateTimeColumn>
            <telerik:TreeListEditCommandColumn UniqueName="InsertCommandColumn" ButtonType="ImageButton" HeaderStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
            </telerik:TreeListEditCommandColumn>
        </Columns>
        <EditFormSettings EditFormType="Template" PopUpSettings-Width="700px">
            <FormTemplate>
                <asp:TextBox ID="userid1" runat="server" Text='<%# Bind("UserId") %>' Visible="false"></asp:TextBox>

                <telerik:RadDateTimePicker ID="creationdate1" runat="server" SelectedDate='<%# Bind("CreationDate") %>' Visible="false"></telerik:RadDateTimePicker>
                <asp:ValidationSummary runat="server" HeaderText="Bei Ihrer Eingabe gab es Fehler:" />
                <asp:Table runat="server">
                    <asp:TableRow>
                        <asp:TableHeaderCell>
                            Name
                        </asp:TableHeaderCell>
                        <asp:TableCell>
                            <asp:TextBox ID="tbName" runat="server" Text='<%# Bind("Name") %>' />
                            <asp:RequiredFieldValidator runat="server" ControlToValidate="tbName" ErrorMessage="Name muss angegeben werden.">
                                    *
                            </asp:RequiredFieldValidator>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableHeaderCell>
                            Beschreibung
                        </asp:TableHeaderCell>
                        <asp:TableCell>
                            <asp:TextBox ID="tbDescription" runat="server" Text='<%# Bind("Description") %>' Width="300" Height="200" TextMode="MultiLine" />
                            <asp:RequiredFieldValidator runat="server" ControlToValidate="tbDescription" ErrorMessage="Beschreibung muss angegeben werden.">
                                    *
                            </asp:RequiredFieldValidator>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableHeaderCell>
                            Globale Kategorie
                        </asp:TableHeaderCell>
                        <asp:TableCell>
                            <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("IsGlobalCategory")%>'></asp:CheckBox>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableHeaderCell>
                            Globaler Inhalt
                        </asp:TableHeaderCell>
                        <asp:TableCell>
                            <asp:CheckBox ID="cbIsActive" runat="server" Checked='<%# Bind("ContainsGlobalContent")%>'></asp:CheckBox>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableHeaderCell>
                            Aktiviert
                        </asp:TableHeaderCell>
                        <asp:TableCell>
                            <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("IsActive")%>'></asp:CheckBox>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Button ID="btnUpdate2" Text='<%# (Container is TreeListEditFormInsertItem) ? "Insert" : "Update" %>'
                                runat="server" CommandName='<%# (Container is TreeListEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button>
                        </asp:TableCell>
                        <asp:TableCell>

                            <asp:Button ID="btnCancel2" Text="Cancel" runat="server" CausesValidation="False"
                                CommandName="Cancel"></asp:Button>
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
            </FormTemplate>
        </EditFormSettings>
    </telerik:RadTreeList>

    <asp:EntityDataSource ID="MediaAssetGroups" runat="server"
        ConnectionString="name=X_DatabaseContainer"
        DefaultContainerName="X_DatabaseContainer" EnableFlattening="False"
        EntitySetName="TreeElementSet" EntityTypeFilter="MediaCategory" EnableInsert="True" EnableDelete="True" EnableUpdate="True"
        Include="" OrderBy="it.Name ASC"
        Where="it.IsDeleted = false">
    </asp:EntityDataSource>

The Problem now is, that everything works fine except of inserting items below other items. Then the freshly created item will show up below root and not the selected parent.

The Id and the TreeElementId are of type Guid.

Has anybody a suggestion for this behaviour?

2 Answers, 1 is accepted

Sort by
0
PPaulsen
Top achievements
Rank 1
answered on 04 Nov 2014, 01:19 PM
Hm... can't edit, so as a reply:

<telerik:RadTreeList runat="server" DataKeyNames="Id" ParentDataKeyNames="TreeElementId" DataSourceID="MediaAssetGroups" AutoGenerateColumns="false" ID="rtlCategories" OnItemInserted="rtlCategories_ItemInserted">
    <Columns>
        <telerik:TreeListBoundColumn DataField="Id" HeaderText="ID" ReadOnly="false"
            UniqueName="EmployeeID" HeaderStyle-Width="60px" ForceExtractValue="Always" Visible="false">
        </telerik:TreeListBoundColumn>
        <telerik:TreeListBoundColumn DataField="Name" HeaderText="Name" ReadOnly="false"
            Visible="true">
        </telerik:TreeListBoundColumn>
        <telerik:TreeListBoundColumn DataField="Description" HeaderText="Beschreibung" ReadOnly="false"
            Visible="true">
        </telerik:TreeListBoundColumn>
        <telerik:TreeListCheckBoxColumn DataField="IsGlobalCategory" DefaultInsertValue="true" HeaderText="Globale Kategorie">
        </telerik:TreeListCheckBoxColumn>
        <telerik:TreeListCheckBoxColumn DataField="ContainsGlobalContent" DefaultInsertValue="false" HeaderText="Globaler Inhalt" Visible="true">
        </telerik:TreeListCheckBoxColumn>
        <telerik:TreeListCheckBoxColumn DataField="IsActive" DefaultInsertValue="true" HeaderText="Aktiv">
        </telerik:TreeListCheckBoxColumn>
        <telerik:TreeListCheckBoxColumn DataField="IsDeleted" DefaultInsertValue="false" HeaderText="Gelöscht" Visible="false">
        </telerik:TreeListCheckBoxColumn>
        <telerik:TreeListBoundColumn DataField="TreeElementId" ReadOnly="false">
        </telerik:TreeListBoundColumn>
        <telerik:TreeListBoundColumn DataField="UserId" HeaderText="Creator" ReadOnly="false"
            Visible="false" />
 
        <telerik:TreeListDateTimeColumn DataField="CreationDate" HeaderText="Erstelldatum" ReadOnly="false" Visible="false"></telerik:TreeListDateTimeColumn>
        <telerik:TreeListEditCommandColumn UniqueName="InsertCommandColumn" ButtonType="ImageButton" HeaderStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
        </telerik:TreeListEditCommandColumn>
    </Columns>
    <EditFormSettings EditFormType="Template" PopUpSettings-Width="700px">
        <FormTemplate>
            <asp:TextBox ID="userid1" runat="server" Text='<%# Bind("UserId") %>' Visible="false"></asp:TextBox>
 
            <telerik:RadDateTimePicker ID="creationdate1" runat="server" SelectedDate='<%# Bind("CreationDate") %>' Visible="false"></telerik:RadDateTimePicker>
            <asp:ValidationSummary runat="server" HeaderText="Bei Ihrer Eingabe gab es Fehler:" />
            <asp:Table runat="server">
                <asp:TableRow>
                    <asp:TableHeaderCell>
                        Name
                    </asp:TableHeaderCell>
                    <asp:TableCell>
                        <asp:TextBox ID="tbName" runat="server" Text='<%# Bind("Name") %>' />
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="tbName" ErrorMessage="Name muss angegeben werden.">
                                *
                        </asp:RequiredFieldValidator>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableHeaderCell>
                        Beschreibung
                    </asp:TableHeaderCell>
                    <asp:TableCell>
                        <asp:TextBox ID="tbDescription" runat="server" Text='<%# Bind("Description") %>' Width="300" Height="200" TextMode="MultiLine" />
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="tbDescription" ErrorMessage="Beschreibung muss angegeben werden.">
                                *
                        </asp:RequiredFieldValidator>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableHeaderCell>
                        Globale Kategorie
                    </asp:TableHeaderCell>
                    <asp:TableCell>
                        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("IsGlobalCategory")%>'></asp:CheckBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableHeaderCell>
                        Globaler Inhalt
                    </asp:TableHeaderCell>
                    <asp:TableCell>
                        <asp:CheckBox ID="cbIsActive" runat="server" Checked='<%# Bind("ContainsGlobalContent")%>'></asp:CheckBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableHeaderCell>
                        Aktiviert
                    </asp:TableHeaderCell>
                    <asp:TableCell>
                        <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("IsActive")%>'></asp:CheckBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell>
                        <asp:Button ID="btnUpdate2" Text='<%# (Container is TreeListEditFormInsertItem) ? "Insert" : "Update" %>'
                            runat="server" CommandName='<%# (Container is TreeListEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button>
                    </asp:TableCell>
                    <asp:TableCell>
 
                        <asp:Button ID="btnCancel2" Text="Cancel" runat="server" CausesValidation="False"
                            CommandName="Cancel"></asp:Button>
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
        </FormTemplate>
    </EditFormSettings>
</telerik:RadTreeList>
 
<asp:EntityDataSource ID="MediaAssetGroups" runat="server"
    ConnectionString="name=X_DatabaseContainer"
    DefaultContainerName="X_DatabaseContainer" EnableFlattening="False"
    EntitySetName="TreeElementSet" EntityTypeFilter="MediaCategory" EnableInsert="True" EnableDelete="True" EnableUpdate="True"
    Include="" OrderBy="it.Name ASC"
    Where="it.IsDeleted = false">
</asp:EntityDataSource>
0
Kostadin
Telerik team
answered on 07 Nov 2014, 11:40 AM
Hi Aljoscha,

In order to add a new item under some item you need to gets its ID first and set it as a ParentID of the new item so basically you can not use Guid value. I would recommend you to examine the following live example which demonstrates how to achiever that.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeList
Asked by
PPaulsen
Top achievements
Rank 1
Answers by
PPaulsen
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or