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

Setting values in AutoComplete Box

14 Answers 1007 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Vipul
Top achievements
Rank 1
Vipul asked on 17 Jan 2013, 05:07 PM
I am facing a couple of issues:

  1. How do I assign values to the autocomplete box?
    Here is how I was doing to the normal text box:
    txtIssTitle.Text = ds.Tables[0].Rows[0]["ISSUE TITLE"].ToString();

    I have now replaced the text box with the autocomplete box. The text I want to display in the autocomplete box upon user click of a Retrieve button will already be part of the entries in the autocomplete box. I just can't figure out how to set and display it in the box.
  2. How do I Left align the text in the box? Right now it's all center aligned.

Though I have opened a support ticket for this but it is kind of urgent for me to find a solution for this since I have to show it to the users asap.

Thanks!

14 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Jan 2013, 04:13 AM
Hi Vipul,

1) Try the following code snippet to add default entries to the RadAutoCompleteBox.

C#:
RadAutoCompleteBox1.Entries.Add(new AutoCompleteBoxEntry(ds.Tables[0].Rows[0]["ISSUE TITLE"].ToString(), ds.Tables[0].Rows[0]["ISSUE TITLE"].ToString() ));

2) Try overriding the default CSS as follows to left align the text in the RadAutoCompleteBox.

CSS:
<style type="text/css">
    .RadAutoCompleteBox .racTextToken
    {
        padding-left: 0px !important;
        float: left !important;
    }
</style>

Hope this helps.

Regards,
Princy.
0
Vipul
Top achievements
Rank 1
answered on 18 Jan 2013, 05:35 AM
Thanks! Solution for 1st one works great.
But for the left alignment of text in RadAutoCompleteBox, I did override the CSS but even then the text shows up in the center. Anything that I might have missed?
0
Princy
Top achievements
Rank 2
answered on 21 Jan 2013, 03:55 AM
Hi,

I was not able to replicate the issue that you are facing. Following is the complete code that I tried to achieve your scenario. Attached is the screenshot.

CSS:
<style type="text/css">
    .RadAutoCompleteBox .racTextToken
    {
        padding-left: 0px !important;
        float: left !important;
    }
</style>

ASPX:
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" InputType="Text" ... >
</telerik:RadAutoCompleteBox>

Please elaborate your scenario with full code if it doesn't helps.

Regards,
Princy.
0
Vipul
Top achievements
Rank 1
answered on 21 Jan 2013, 06:37 AM
I tried adding another AutoCompleteBox to the page. As soon as I set the 'Allow Custom Entry' property to True, the text display aligns to Center instead of Left. Then if I remove that property, it aligns to Left.
0
Princy
Top achievements
Rank 2
answered on 22 Jan 2013, 05:32 AM
Hi Vipul,

Try the following CSS to achieve your scenario.

CSS:
<style type="text/css">
    .RadAutoCompleteBox .racInput
    {
        text-indent: 0px !important;
    }
</style>

Hope this helps.

Regards,
Princy.
0
GACA
Top achievements
Rank 2
answered on 14 Aug 2014, 09:37 AM
I am using Right to Left direction.

I tried 

<style type="text/css">    .RadAutoCompleteBox .racTextToken    {        padding-right: 0px !important;        float: right!important;    }</style>

But it doesnot change still on the left side only. Please check the attached screenshot. 
0
Princy
Top achievements
Rank 2
answered on 14 Aug 2014, 10:40 AM
Hi,

Try below CSS which works fine at my end. Please take a look into the attached screenshot also.

CSS:
.RadAutoCompleteBox .racToken
{
    float:right !important;
}

Thanks,
Princy.
0
GACA
Top achievements
Rank 2
answered on 14 Aug 2014, 11:12 AM
Excellent works fine. ***** (5 stars) to Telerik support. Really appreciated for quick response.
0
zznbilly
Top achievements
Rank 1
answered on 11 Aug 2015, 11:40 AM

1.Analyzing overriding CSS, how can I change (per example) the bordercolor of a ​RadAutoCompleteBox using code-behind?

2.Speaking about values is there a way to add online values into the list that the RadAutoCompleteBox refers?

Thnx in advance :)

0
zznbilly
Top achievements
Rank 1
answered on 11 Aug 2015, 11:54 AM
"Add online values" means to update the datasource of RadAutoCompleteBox adding the typed new value in it. Is it possible?
0
Ivan Danchev
Telerik team
answered on 13 Aug 2015, 02:41 PM
Hello,

1. You can set the border color from code-behind by setting a CSS class to the RadAutoCompleteBox. For instance if you have the following CSS rule with the custom class "customAutoCompleteBox" added to the selector:
html .customAutoCompleteBox .racTokenList {
    border-color: red;
}

You can set that class to the RadAutoCompleteBox CssClass property:
RadAutoCompleteBox1.CssClass = "customAutoCompleteBox";

2. You can add the typed text to the data source in the RadAutoCompleteBox OnTextChanged event handler. In the handler e.Text would hold the typed text, so for instance if your source is an Sql database you can add a new record with an Insert statement passing the value of e.Text.

Regards,
Ivan Danchev
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
zznbilly
Top achievements
Rank 1
answered on 14 Aug 2015, 07:43 AM
Ivan, first checked. Works fine. Thnx a lot. Second one still to come :)
0
Ivan Danchev
Telerik team
answered on 18 Aug 2015, 01:37 PM
Hello,

I am glad it works as expected. Let us know if you need further assistance with the database insertion of the typed text.


Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
zznbilly
Top achievements
Rank 1
answered on 18 Aug 2015, 08:15 PM
I tried e.text but the postback is really annoying. I tried a popup-form from javascript and worked fine after a hard effort :)
Tags
AutoCompleteBox
Asked by
Vipul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Vipul
Top achievements
Rank 1
GACA
Top achievements
Rank 2
zznbilly
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or