RadAutoCompleteBox in EditItemTemplate

5 posts, 1 answers
  1. Bernie
    Bernie avatar
    27 posts
    Member since:
    Apr 2008

    Posted 02 Nov 2012 Link to this post

    Hi!
    I have a radgrid and try to implement the radautocomplete object in an edititemtemplate like this:

    <EditItemTemplate>
        <telerik:RadAutoCompleteBox
            ID="RadAutoCompleteBox1" runat="server"
            Width="400" DropDownWidth="200"
            DataTextField="Field1"
            DataValueField="Field1"
            DataSourceID="ADS_Field1"
            InputType="Text"
            Delimiter=";"
            AllowCustomEntry="true"
            TokensSettings-AllowTokenEditing="true"
            Text='<%# Bind("Field1") %>'>
        </telerik:RadAutoCompleteBox>
    </EditItemTemplate>

    1. Problem: the binded field value does not appear in the edit form
    2. If I change the inputtype to "Token" you cannot write in this field
    3. how can I remove the delimiter before update, because I don't want to have it in my database

    Thank you!
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 08 Nov 2012 Link to this post

    Hello Peter,

    In order to set an initially selected Entry in RadAutoCompleteBox you need to add a new entry to control Entries collection.
    You can make this at RadGrid.OnItemDataBound event:
    <EditFormSettings EditFormType="Template">
        <FormTemplate>
        ...
              <telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1"
                          runat="server"></telerik:RadAutoCompleteBox>
       ...                    
        </FormTemplate>
    </EditFormSettings>
    protected void OnItemDataBoundHandler(object sender, GridItemEventArgs e)
    {
     
        if (e.Item.IsInEditMode)
        {
            GridEditableItem item = (GridEditableItem)e.Item;
            if (!(e.Item is IGridInsertItem))
            {
     
                RadAutoCompleteBox auto = (RadAutoCompleteBox)item.FindControl("RadAutoCompleteBox1");
                auto.Entries.Add(new AutoCompleteBoxEntry(item["CategoryName"].Text, item["CategoryID"].Text));
     
            }
     
        }
    }

    Kind regards,
    Kalina
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bernie
    Bernie avatar
    27 posts
    Member since:
    Apr 2008

    Posted 13 Nov 2012 Link to this post

    Thank you!

    i made following code which works for me, but I cannot set the focus to the field. I hope you have an idea!

    protected void RG_Archiv_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode)
            {
                GridEditableItem item = (GridEditableItem)e.Item;
                if (!(e.Item is IGridInsertItem))
                {
                    string Mandant_Name = ((DataRowView)e.Item.DataItem)["Mandant_Name"].ToString().Trim();
                    RadAutoCompleteBox auto = (RadAutoCompleteBox)item.FindControl("RACB_Mandant_Name");
                    auto.Entries.Add(new AutoCompleteBoxEntry(Mandant_Name, Mandant_Name));
     
                    string Gegner_Name = ((DataRowView)e.Item.DataItem)["Gegner_Name"].ToString().Trim();
                    RadAutoCompleteBox auto2 = (RadAutoCompleteBox)item.FindControl("RACB_Gegner_Name");
                    auto2.Entries.Add(new AutoCompleteBoxEntry(Gegner_Name, Gegner_Name));
                     
                    auto.Focus();
                }
            }
        }

    Thank you!


  5. Answer
    Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 16 Nov 2012 Link to this post

    Hi Peter,

    Let me suggest you handle the OnClientLoad event of the RadAutoComplete that you nest in RadGrid EditItemTemplate, and focus the input element in this way:

    <script type="text/javascript">
        function OnClientLoad(sender) {
            sender.get_inputElement().focus();
        }
             
    </script>

    Regards,
    Kalina
    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.
  6. Bernie
    Bernie avatar
    27 posts
    Member since:
    Apr 2008

    Posted 20 Nov 2012 Link to this post

    Hi!

    Thank you, but this doesn't work for me...
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017