Get the data from the new row InPlace

8 posts, 0 answers
  1. Franklin
    Franklin avatar
    10 posts
    Member since:
    Jul 2012

    Posted 10 Jul 2012 Link to this post

    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>


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Jul 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Franklin
    Franklin avatar
    10 posts
    Member since:
    Jul 2012

    Posted 11 Jul 2012 Link to this post

    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?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Jul 2012 Link to this post

    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.
  6. Franklin
    Franklin avatar
    10 posts
    Member since:
    Jul 2012

    Posted 12 Jul 2012 Link to this post

    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,
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Jul 2012 Link to this post

    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.
  8. Franklin
    Franklin avatar
    10 posts
    Member since:
    Jul 2012

    Posted 13 Jul 2012 Link to this post

    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.
  9. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 16 Jul 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017