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

3 Questions! Please Respond Urgently!

6 Answers 91 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Diana
Top achievements
Rank 1
Diana asked on 07 Mar 2013, 05:58 PM
Hi,

I have 3 questions:

1. I have set the AutoCompleteBox to allow only single mode selection; however, after the user has picked the data I noticed that the control still displays like a linefeed / space as if the user is still allowed to enter more [but it doesn't allow him to enter more than one; I mean it's only adding this space] and I'm not ok with this behaviour. Suggestions? [Pictures attached].

2. Let's say the page I have saves and displays the details of a certain item; and I use an AutoCompleteBox for the country of origin field. In saving, I won't have a problem since the AutoCompleteBox will display proper data for the user to choose from. But in displaying the saved database records, sometimes the country database field might not have a proper value and still be valid; like "USA" instead of "United States", I want to still be able to view that kind of data in the AutoCompleteBox regardless. Is this possible? How can I do it?

3. After the user has entered the letters to search for in the AutoCompleteBox, you know there's like a one second delay before displaying the data for him. How can I add like a "loading..." text in the AutoCompleteBox until the data is retrieved for him?

Many thanks!

6 Answers, 1 is accepted

Sort by
0
Diana
Top achievements
Rank 1
answered on 10 Mar 2013, 05:41 AM
Anyone?
0
Princy
Top achievements
Rank 1
answered on 11 Mar 2013, 05:32 AM
Hello Diana,

I have tried the first and third scenario. Can you explain a bit more on your second requirement?

Regarding the first question, The RadAutoCompleteBox displays like a linefeed / space after an item is selected as if the user is still allowed to enter more. That is the default nature even if you are setting the TextSettings SelectionMode to Single. I have a suggestion like once the user picked an item from the RadAutoCompleteBox drop-down, you can change the focus to some other control so that the linefeed is not displayed. Please check the following code.

ASPX:
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" EmptyMessage="Enter Name"
    InputType="Text" DataSourceID="SqlDataSource2" OnClientDropDownClosed="OnClientDropDownClosed"
    DataTextField="ContactName">
    <TextSettings SelectionMode="Single" />
</telerik:RadAutoCompleteBox>
<br />
<telerik:RadTextBox ID="RadTextBox1" runat="server">
</telerik:RadTextBox>

JavaScript:
<script type="text/javascript">
    function OnClientDropDownClosed(sender, args) {
        document.getElementById("RadTextBox1").focus();
    }
</script>

Regarding your third question, If there is some delay in populating the RadAutoCompleteBox drop-down items, you can use Ajax to explicitly display an AjaxLoadingPanel and hide it after the items are  populated. You can attach the OnClientRequesting and OnClientRequested client side events to display an AjaxLoadingPanel. To have a clear idea on explicitly showing and hiding AjaxLoadingPanel, please check this forum thread.

Thanks,
Princy.
0
Diana
Top achievements
Rank 1
answered on 11 Mar 2013, 05:59 AM
Thank you so much Princy. This is very helpful!

What I meant in the second question; is that I use the AutoCompleteBox to let the user fill the Country field for example. The list of countries is retrieved from a database table and so I know for each entry what is the desired text and value. But, in my case the data is sometimes retrieved from another source; through EDI for example. In this case, I won't have control over the Country values that the user might enter, but I still want to be able to display them. Will "AllowCustomEntry" property solve this problem for me?

I have one more question, I need to add another attrribute [other than text and value] to each entry of the AutoCompleteBox. I was able to do this using:

foreach (DataRow row in data.Rows)
        {
            AutoCompleteBoxItemData childNode = new AutoCompleteBoxItemData();
            childNode.Text = row["ContactName"].ToString();
            childNode.Attributes.Add("ContactTitle", row["ContactTitle"].ToString());
            childNode.Attributes.Add("City", row["City"].ToString());
            childNode.Attributes.Add("Country", row["Country"].ToString());
            childNode.Attributes.Add("Phone", row["Phone"].ToString());
            childNode.Attributes.Add("Photo", System.Web.VirtualPathUtility.ToAbsolute("~/Img/Northwind/Customers/" + row["CustomerID"].ToString() + ".jpg"));
            result.Add(childNode);
        }


However, I couldn't by any chance get these attributes through JavaScript. I was able to only get and display text and value. This code snippet is taken from the demo here http://demos.telerik.com/aspnet-ajax/autocompletebox/examples/templates/defaultcs.aspx but I don't need a template; I need the same scenario but to use these attributes through JavaScript. Ideas? :)
0
Bozhidar
Telerik team
answered on 12 Mar 2013, 08:31 AM
Hello Diana,

Currently RadAutoCompleteBox doesn't provide access to custom attributes on the client, however we will include this functionality in our next Service Pack, or the next official release if we don't have enough time.

As for your other question: Yes, if you want to allow the user to type any text into the AutoCompleteBox and this text to be saved as an entry, you have to set the AllowCustomEntry property to true.
 

Kind regards,
Bozhidar
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
Mohamed
Top achievements
Rank 1
answered on 14 Apr 2013, 09:49 AM
I was asking about the first issue. I've read the workaround and I feel it's a dirty workaround !
0
chetna
Top achievements
Rank 1
answered on 15 Dec 2016, 08:41 AM

I wanted to color the specific attribute at the time of binding . Please help me.

 

Tags
AutoCompleteBox
Asked by
Diana
Top achievements
Rank 1
Answers by
Diana
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Bozhidar
Telerik team
Mohamed
Top achievements
Rank 1
chetna
Top achievements
Rank 1
Share this question
or