Clear or customize the text of RadComboBox with CheckBox

12 posts, 0 answers
  1. Fatima
    Fatima avatar
    18 posts
    Member since:
    Aug 2012

    Posted 19 Sep 2012 Link to this post

    Hi

    I use a RadComboBox with checkboxes.

    I really need to clear or customize it's text, but there is no property for it.

    ChekedItemTexts propery has just two options and it has not an option such as none , ...

    Below command is not work too:

        RadComboox1.text = "";

    How can I clear its text?

    thanks.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Sep 2012 Link to this post

    Hi Fatima,

    I suppose you want to clear the RadCombobox text. Here is the sample code that I tried.

    JS:
    function OnClientLoad(sender, args)
    {
      sender.set_text("");
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 19 Sep 2012 Link to this post

    Hello Fatima,

    When you use RadComboBox CheckBoxes feature - the text of the control displays the texts of the checked items.
    If you want to clear the text in the RadComboBox - the proper approach is to "uncheck" the checked items programmatically by setting the Checked property of each item to "false".

    foreach (RadComboBoxItem item in RadComboBox1.CheckedItems)
    {
        item.Checked = false;
    }

    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.
  5. Fatima
    Fatima avatar
    18 posts
    Member since:
    Aug 2012

    Posted 21 Sep 2012 Link to this post

    Hi Kalina

    Thanks for your reply, but I want that CheckBoxes have mark (if user wants)

    But I need to clear it's text, because I want display RadAjaxLodingPanel in it during it's post-back. I did it but the text of ComboBox is ugly and LoadingPanel is not appear correctly.

    Thanks
  6. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 27 Sep 2012 Link to this post

    Hi Fatima,

    I am afraid that the checked items texts are always displayed in RadComboBox input .
    This is a behaviour by design - simply the RadComboBox shows which items are checked.

    If you want to clear the text in the input - you should uncheck the checked items.
    cleared automatically.

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

    Posted 29 Sep 2012 Link to this post

    Hi Kalina Kalin
    Many thanks of you. Your solution was worked for me; I use it when I want to clear its text.
    (but I must return its status to primary state after it)

    foreach (RadComboBoxItem item in RadComboBox1.CheckedItems)
    {
        item.Checked = false;
    }
  8. NEX
    NEX avatar
    84 posts
    Member since:
    Aug 2007

    Posted 16 Jan 2014 Link to this post

    I want the checked items to remain checked. I just want to build my own display text string to show instead of 2 checked etc.
    How do I override your default checkeditems text function?

    You should add an option to use the text property instead.
  9. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jan 2014 Link to this post

    Hi,

    One approach is that you can customize the default CheckedItem string by using ItemsCheckedString property of RadComboBox as follows.

    ASPX:
    <Localization ItemsCheckedString="Checked" />

    Another approach is that you can set the text for RadComboBox from ClientSide as follows.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server"  DataSourceID="SqlDataSource1"
        DataTextField="Name" OnClientDropDownClosing="OnClientDropDownClosing1" CheckBoxes="true" >
    </telerik:RadComboBox>

    JavaScript:
    <script type="text/javascript">
        function OnClientDropDownClosing1(sender, args) {
            sender.set_text("Updated");
        }
    </script>

    Thanks,
    Shinu.
  10. NEX
    NEX avatar
    84 posts
    Member since:
    Aug 2007

    Posted 16 Jan 2014 Link to this post

    Thanks! But how can I pass a string defined on the server-side to it. I want to create a string on page load to place in the text field.
  11. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Jan 2014 Link to this post

    Hi,

    As a  work around please try the following code snippet which works fine at my end.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="true" CheckBoxes="true"
        OnItemChecked="RadComboBox1_ItemChecked">
        <Items>
            <telerik:RadComboBoxItem runat="server" Text="Item1" />
            <telerik:RadComboBoxItem runat="server" Text="Item2" />
            <telerik:RadComboBoxItem runat="server" Text="Item3" />
        </Items>
    </telerik:RadComboBox>

    C#:
    string test = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        //assign value to test variable
            test = "demo";
    }
    protected void RadComboBox1_ItemChecked(object sender, RadComboBoxItemEventArgs e)
    {
        //passing the value to client side
        string script = "function f(){setValue('"+test+"'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); 
    }

    JavaScript:
    <script type="text/javascript">
        function setValue(text) {
            var combo = $find("<%=RadComboBox1.ClientID %>");
            combo.set_text(text);
        }
    </script>

    Thanks,
    Shinu.
  12. Naveen
    Naveen avatar
    1 posts
    Member since:
    Dec 2015

    Posted 18 Dec 2015 in reply to Shinu Link to this post

    Hi Shinu,

     

    I tried the above code but i am getting setValue is undefined error.

     

    Thanks,

    Naveen.

  13. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 23 Dec 2015 Link to this post

    Hi Naveen,

    Could you elaborate on what exactly you want to achieve?

    Regards,
    Eyup
    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017