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

AutoCompleteBox.Entries empty on AJAX postback

2 Answers 129 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
SEE Global IT Development Team
Top achievements
Rank 2
SEE Global IT Development Team asked on 25 Mar 2014, 10:13 PM
Hello,

I've encountered some surprising behaviour with the RadAutoCompleteBox.Entries property during the implementation of a custom DataSourceSelect event.  Unless I also implement the EntryAdded and EntryRemoved events, the items added to or removed from the box by the user do not show up in the Entries collection of the control in the DataSourceSelect event handler.

I have an AutoCompleteBox defined as follows:
<telerik:RadAutoCompleteBox ID="titles" runat="server" InputType="Token" TokensSettings-AllowTokenEditing="false" DataTextField="Title" DataValueField="TitleID" OnDataSourceSelect="titles_DataSourceSelect" OnEntryAdded="titles_EntryAdded" Width="400px"></telerik:RadAutoCompleteBox>

I have a method that queries my back end database with the text entered by the user and sets the data source.  Before querying the database, I get the items that have already been added to the control and include their IDs in the database queries, so that they can be filtered out of the drop down of matches.  In other words, if a user has types in text, picked an item form the dropdown and added it to the control, I ensure that the same item does not appear again in the dropdown.

        protected void titles_DataSourceSelect(object sender, AutoCompleteBoxDataSourceSelectEventArgs e)<br>        {<br>            List<int> exclude = new List<int>();<br>            foreach (AutoCompleteBoxEntry entry in titles.Entries)<br>            {<br>                int id = -1;<br>                if (int.TryParse(entry.Value, out id))<br>                {<br>                    exclude.Add(id); <br>                }<br>            }<br><br>            titles.DataSource = Database.SearchDimension("Title", e.FilterString, exclude); // call DAL<br>        }<br>

I have put a RadAjaxManager on the page and given the AutoCompleteBox the ability to ajaxically update itself.
         <telerik:AjaxSetting AjaxControlID="titles">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="titles" UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
             </telerik:AjaxSetting>

But the above doesn't work.  When my DataSourceSelect event handler fires, the Entries collection of the control is always empty.

If I implement empty event handlers for EntryAdded and EntryRemoved, it works as expected, and the Entries collection contains the items which have been previously selected by the user.

<telerik:RadAutoCompleteBox ID="titles" runat="server" InputType="Token" TokensSettings-AllowTokenEditing="false" DataTextField="Title" DataValueField="TitleID" OnDataSourceSelect="titles_DataSourceSelect" OnEntryAdded="titles_EntryAdded" OnEntryRemoved="titles_EntryRemoved" Width="400px"></telerik:RadAutoCompleteBox>

        protected void titles_EntryAdded(object sender, AutoCompleteEntryEventArgs e)<br>        {<br>        }<br><br>        protected void titles_EntryRemoved(object sender, AutoCompleteEntryEventArgs e)<br>        {<br>        }

If I eliminate either one of these two event handlers, the corresponding action is not taken into account in the Entries collection.  So if I remove EntryAdded, items I add to the control are not taken into account.  If I remove EntryRemoved, when I add and then remove an item, it still shows up in the Entries collection.

On a full page postback triggered by something else, the Entries collection always correctly lists items really entered in the web form.

I am running this in a SharePoint 2010 custom Application page.

This looks like a bug to me, but maybe I've misunderstood the API for this control and am not using it correctly.



2 Answers, 1 is accepted

Sort by
0
SEE Global IT Development Team
Top achievements
Rank 2
answered on 26 Mar 2014, 02:14 PM
Sorry for the badly formatted code blocks in my initial message.
Also, just to specify, I am using the 2014 Q1 release, 2014.1.225.35.
0
Nencho
Telerik team
answered on 28 Mar 2014, 12:35 PM
Hello,

I was able to replicate the described issue and I have forwarded it to our developer team for further investigation. Thank you for pointing this issue out. In addition, I have updated your Telerik Points for reporting for that problem.

Regards,
Nencho
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
AutoCompleteBox
Asked by
SEE Global IT Development Team
Top achievements
Rank 2
Answers by
SEE Global IT Development Team
Top achievements
Rank 2
Nencho
Telerik team
Share this question
or