Setting values in AutoComplete Box

15 posts, 0 answers
  1. Vipul
    Vipul avatar
    6 posts
    Member since:
    Aug 2012

    Posted 17 Jan 2013 Link to this post

    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!
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jan 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vipul
    Vipul avatar
    6 posts
    Member since:
    Aug 2012

    Posted 17 Jan 2013 Link to this post

    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?
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Jan 2013 Link to this post

    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.
  6. Vipul
    Vipul avatar
    6 posts
    Member since:
    Aug 2012

    Posted 21 Jan 2013 Link to this post

    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.
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Jan 2013 Link to this post

    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.
  8. GACA
    GACA avatar
    7 posts
    Member since:
    Apr 2013

    Posted 14 Aug 2014 in reply to Princy Link to this post

    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. 
  9. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Aug 2014 in reply to GACA Link to this post

    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.
  10. GACA
    GACA avatar
    7 posts
    Member since:
    Apr 2013

    Posted 14 Aug 2014 in reply to Princy Link to this post

    Excellent works fine. ***** (5 stars) to Telerik support. Really appreciated for quick response.
  11. V
    V avatar
    7 posts
    Member since:
    Jun 2013

    Posted 11 Aug 2015 Link to this post

    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 :)

  12. V
    V avatar
    7 posts
    Member since:
    Jun 2013

    Posted 11 Aug 2015 in reply to V Link to this post

    "Add online values" means to update the datasource of RadAutoCompleteBox adding the typed new value in it. Is it possible?
  13. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 13 Aug 2015 Link to this post

    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.
     
  14. V
    V avatar
    7 posts
    Member since:
    Jun 2013

    Posted 14 Aug 2015 in reply to Ivan Danchev Link to this post

    Ivan, first checked. Works fine. Thnx a lot. Second one still to come :)
  15. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 18 Aug 2015 Link to this post

    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
  16. V
    V avatar
    7 posts
    Member since:
    Jun 2013

    Posted 18 Aug 2015 in reply to Ivan Danchev Link to this post

    I tried e.text but the postback is really annoying. I tried a popup-form from javascript and worked fine after a hard effort :)
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017