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

RadAutoCompleteBox in EditItemTemplate

4 Answers 226 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Bernie
Top achievements
Rank 1
Bernie asked on 02 Nov 2012, 04:13 PM
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!

4 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 08 Nov 2012, 08:22 AM
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.
0
Bernie
Top achievements
Rank 1
answered on 13 Nov 2012, 09:20 AM
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!


0
Accepted
Kalina
Telerik team
answered on 16 Nov 2012, 10:27 AM
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.
0
Bernie
Top achievements
Rank 1
answered on 20 Nov 2012, 02:27 PM
Hi!

Thank you, but this doesn't work for me...
Tags
AutoCompleteBox
Asked by
Bernie
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Bernie
Top achievements
Rank 1
Share this question
or