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

Get the data from the new row InPlace

7 Answers 101 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Franklin
Top achievements
Rank 1
Franklin asked on 10 Jul 2012, 03:57 PM
I've got a treelist with 7 columns, the first one has the check selector, the second one is a TreeListBoundColumn and the others are TreeListTemplateColumn between date fields, comboboxes and numeric text boxes, I PRESS THE ADD BUTTON ('plus icon' given by the treelist template) and fill the data, HOW CAN I GET THE DATA I JUST PUT IN THE FIELDS (specially the templates) TO INSERT THEM IN DATABASE WHEN I PRESS THE SAVE ICON (check icon)?
THANKS IN ADVANCE

This is my tree list code:

<telerik:RadTreeList ID="tasksListRadTreeList" runat="server" Width="100%"

                DataKeyNames="IdTask"

                ParentDataKeyNames="IdFather" AutoGenerateColumns="False"

                EditMode="InPlace" AllowPaging="False"

              

                oneditcommand="tasksListRadTreeList_EditCommand"

                oninsertcommand="tasksListRadTreeList_InsertCommand" 

                onneeddatasource="tasksListRadTreeList_NeedDataSource"

                onitemdatabound="tasksListRadTreeList_ItemDataBound">

                        <Columns>

                            <telerik:TreeListSelectColumn HeaderStyle-Width="38px">

                            </telerik:TreeListSelectColumn>

                                        

                            <telerik:TreeListBoundColumn DataField="NameTask" HeaderText="Title" UniqueName="NameTask" SortExpression="NameTask" HeaderStyle-Width="30%" />

                            <telerik:TreeListTemplateColumn HeaderText="Start Date" DataField="StartDate" UniqueName="StartDate" SortExpression="StartDate" HeaderStyle-Width="80px">

                            <ItemTemplate>

                                <asp:Label ID="label3" runat="server" Text='<%# Eval("StartDate") %>' ToolTip='<%# Eval("EndDate") %>'></asp:Label>

                            </ItemTemplate>

                            <EditItemTemplate>

                                <telerik:RadDatePicker ID="startDateRadDatePicker1" Runat="server" SelectedDate='01/01/2012' Width="80" Calendar-CultureInfo="es-CO" Calendar-DateRangeSeparator=" /">

                                </telerik:RadDatePicker>

                            </EditItemTemplate>

                            </telerik:TreeListTemplateColumn>

                            <telerik:TreeListTemplateColumn HeaderText="End Date" DataField="EndDate" UniqueName="EndDate" SortExpression="EndDate" HeaderStyle-Width="80px">

                            <ItemTemplate>

                                <asp:Label ID="label4" runat="server" Text='<%# Eval("EndDate") %>' ToolTip='<%# Eval("EndDate") %>'></asp:Label>

                            </ItemTemplate>

                            <EditItemTemplate>

                                <telerik:RadDatePicker ID="endDateRadDatePicker" Runat="server" SelectedDate='01/01/2012' Width="80">

                                </telerik:RadDatePicker>

                            </EditItemTemplate>

                            </telerik:TreeListTemplateColumn>                                                    

                            <telerik:TreeListTemplateColumn HeaderText="Priority" DataField="Priority" UniqueName="Priority" SortExpression="Priority" HeaderStyle-Width="60px">

                            <ItemTemplate>

                                <asp:Label ID="label5" runat="server" Text='<%# Eval("Priority") %>' ToolTip='<%# Eval("Priority") %>'></asp:Label>

                            </ItemTemplate>

                            <EditItemTemplate>

                                <telerik:RadComboBox ID="priorityRadComboBox" CheckBoxes="True" ShowDropDownOnTextboxClick="True" runat="server" Culture="es-CO" Width="60px"></telerik:RadComboBox>

                            </EditItemTemplate>

                            </telerik:TreeListTemplateColumn>

                            <telerik:TreeListTemplateColumn HeaderText="% " DataField="Percentage" UniqueName="Percentage" SortExpression="Percentage" HeaderStyle-Width="50px">

                            <ItemTemplate>

                                <asp:Label ID="label6" runat="server" Text='<%# Eval("Percentage") %>' ToolTip='<%# Eval("Percentage") %>'></asp:Label>

                            </ItemTemplate>

                            <EditItemTemplate>

                                <telerik:RadNumericTextBox ID="percentRadNumericTextBox" runat="server" Text='<%# Eval("Percentage") %>' Width="50" MaxLength="3" MaxValue="100" MinValue="0" ShowButton="False" ShowSpinButtons="True"></telerik:RadNumericTextBox>

                            </EditItemTemplate>

                            </telerik:TreeListTemplateColumn>

                           <telerik:TreeListEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" ShowAddButton="True" HeaderStyle-Width="70px" AddRecordText="Agregar Subtarea" CancelText="Cancelar" EditText="Editar Tarea">

                                <ItemStyle CssClass="MyImageButton" />

                            </telerik:TreeListEditCommandColumn>

                        </Columns>

            </telerik:RadTreeList>

            </telerik:RadAjaxPanel>


7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Jul 2012, 06:05 AM
Hello Franklin,

You can access the controls in InsertCommand as shown below.
C#:
protected void RadTreeList1_InsertCommand(object sender, TreeListCommandEventArgs e)
{
   TreeListDataInsertItem item = (TreeListDataInsertItem)e.Item;
    RadComboBox com = (RadComboBox)item.FindControl("priorityRadComboBox");
    RadDatePicker pkr = (RadDatePicker)item.FindControl("endDateRadDatePicker");
}

Thanks,
Shinu.
0
Franklin
Top achievements
Rank 1
answered on 11 Jul 2012, 02:20 PM
Thanks Shinu, 
IT WORKED PERFECTLY..

BUT NOW I GOT THE TROUBLE THAT I WANT TO SHOW  ERROR MESSAGES WHEN THE DATA ARE NOT CORRECTLY INSERTED, 
I VALIDATE THE DATA, THEN I SHOW A MESSAGE IN A LABEL (in case there are errors) BUT THE TREELIST DOES A KIND OF POSTBACK AND HIDES THE FIELDS WHERE I WAS FILLING.

WHAT CAN I DO?
0
Shinu
Top achievements
Rank 2
answered on 12 Jul 2012, 06:40 AM
Hello,

Try adding the label in ItemCreated event of the TreeList.
C#:
protected void RadTreeList1_ItemCreated(object sender, Telerik.Web.UI.TreeListItemCreatedEventArgs e)
{
 if (e.Item is TreeListDataInsertItem)
 {
   TreeListDataInsertItem item = (TreeListDataInsertItem)e.Item;
   Label lbl = new Label();
   lbl.ID = "lbl1";
   lbl.Text = "*";
   lbl.ForeColor = System.Drawing.Color.Red;
   item["UniqueName"].Controls.Add(lbl);
  }
}

Thanks,
Shinu.
0
Franklin
Top achievements
Rank 1
answered on 12 Jul 2012, 07:25 PM
But I still have no how to tell the user what is wrong or what missed when click the save button, because currently when presses the save button the fields just  disappear.

Thanks,
0
Shinu
Top achievements
Rank 2
answered on 13 Jul 2012, 05:39 AM
Hello Franklin,

You can add a RequireFieldValidator in insert mode. Here is the sample code.
C#:
protected void RadTreeList1_ItemCreated(object sender, Telerik.Web.UI.TreeListItemCreatedEventArgs e)
{
 if (e.Item is TreeListDataInsertItem)
 {
   TreeListDataInsertItem item = e.Item as TreeListDataInsertItem;
   RadComboBox combo = (RadComboBox)insertForm.FindControl("RadcomboBox1");
   RequiredFieldValidator requiredFieldValidator1 = new RequiredFieldValidator();
   requiredFieldValidator1.ID = "RequiredFieldValidatorParentPrice";
   requiredFieldValidator1.ControlToValidate = combo.ID;
   requiredFieldValidator1.ErrorMessage = "Required field!";
   item["ColumnUniqueName"].Controls.Add(requiredFieldValidator1);
  }
}
Also check the following demo which explains more on validation.
TreeList / Validation

Thanks,
Shinu.
0
Franklin
Top achievements
Rank 1
answered on 13 Jul 2012, 03:48 PM
You are so kind, it worked as I needed.
Now I am having problems with the tooltips in the treelist

This is the post, maybe you can help me

http://www.telerik.com/community/forums/aspnet-ajax/tooltip/tooltip-treelist-items--problem.aspx 


Thanks a lot.
0
Andrey
Telerik team
answered on 16 Jul 2012, 07:44 AM
Hello,

I have answered your question in the other forum thread, I suggest to continue the discussion there.

Greetings,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeList
Asked by
Franklin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Franklin
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or