Change radcombobox text

5 posts, 0 answers
  1. Ryan
    Ryan avatar
    56 posts
    Member since:
    Apr 2012

    Posted 27 Jul 2012 Link to this post

    Hi ther,
         I have a situation where I hav to change the text of "check all" string in the radCombobox. Can anybody help me with some goodies :)
    Thanks in  advance
    RT
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Jul 2012 Link to this post

    Hi Ryan,

    Try setting the Localization-CheckAllString property of RadComboBox as follows.

    ASPX:
    <telerik:RadComboBox ID="combo" CheckBoxes="true" Localization-CheckAllString="Select all" runat="server" >
    </telerik:RadComboBox>

    Hope this helps.

    Regards,
    Princy.
  3. David
    David avatar
    4 posts
    Member since:
    Oct 2010

    Posted 30 Jul 2012 Link to this post

    I would like to use the RadComboBox localization.checkAllString to change the text when all items are selected, e.g. with all items NOT selected, the checkAllString is "Check All", but when all items ARE selected, I would like to change the text to "Uncheck All". 

    I looked at the demo at http://demos.telerik.com/aspnet-ajax/combobox/examples/programming/clientevents/defaultcs.aspx, but I don't see any client-side event that fires when the 'check all' checkbox is clicked, and I don't see any properties that will tell me if all items are checked.

    Is there a way to dynamically change the "check all" text to "uncheck all"  when all items are checked?

    Thanks
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 31 Jul 2012 Link to this post

    Hi David,

    When user checks the "Check All" checkbox - all RadComboBox items are marked as checked and there is no specific event for that. As a workaround you can try the following code snippet to change the "check all" text to "uncheck all"  when all items are checked and vice versa.

    CSS:
    <style type="text/css">
     .Display
      {
        display: none;
      }
    </style>

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" CheckBoxes="true" AutoPostBack="true" EnableCheckAllItemsCheckBox ="true" OnClientItemChecked="OnClientItemChecked"  >
     <Items>
       .............
     </Items>
    </telerik:RadComboBox>
    <asp:HiddenField ID="hdn" runat="server" />
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" CssClass="Display" />

    JS:
    <script type="text/javascript">
        function pageLoad() {
            var combo = $find("<%= RadComboBox1.ClientID %>");
            var checkall = $telerik.$('.rcbCheckAllItemsCheckBox');
            var hdn = document.getElementById("hdn");
            checkall.change(function () {
                var isChecked = checkall.attr('checked') ? true : false;
                if (isChecked == true) {
                    hdn.value = "1";
                }
                else {
                    hdn.value = "0";
                }
                var btn = document.getElementById("Button1");
                btn.click();
            });
        }
        function OnClientItemChecked(sender, args) {
            debugger;
            var hdn = document.getElementById("hdn");
            var checkall = $telerik.$('.rcbCheckAllItemsCheckBox');
            var isChecked = checkall.attr('checked') ? true : false;
            if (isChecked == true) {
                hdn.value = "1";
                var btn = document.getElementById("Button1");
                btn.click();
            }
            else {
                hdn.value = "0";
            }
        }
    </script>

    C#:
    protected void Button1_Click(object sender, EventArgs e)
     {
      if (hdn.Value == "1")
       {
         RadComboBox1.Localization.CheckAllString = "Uncheck All";
       }
      else if (hdn.Value == "0")
       {
         RadComboBox1.Localization.CheckAllString = "check All";
       }
     }

    Hope this helps.

    Regards,
    Princy.
  5. Tracy Dryden
    Tracy Dryden avatar
    34 posts
    Member since:
    Dec 2005

    Posted 20 Dec 2012 Link to this post

    The code above does not work if you click on the "Select All" row, only if you click the checkbox itself.

    A better way is to add a click event handler to the div containing the select all entry instead:
    var checkalldiv = $telerik.$('div.rcbCheckAllItems');
    checkalldiv.click(function() {
    ...
    });
Back to Top