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

changing text of RadComboBox programmatically

2 Answers 221 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Yazid
Top achievements
Rank 1
Yazid asked on 11 Aug 2014, 12:27 PM
Hi there!
we are using Telerik 2011. So I customized RadComboBox to provide ,,Select All"-feature. So when the ,,Select All"-item is selected a js function registered with OnClientItemChecked  will be called and iterates all other items and selects them. 

As a result the checkboxes of the items are being selected and the content of  input area  is a comma separeted list of texts of the items.

So my question how can I make the input area displaying only the word,,All" when the ,,Select All"-item is selected  and not a list of all items?


Thank you in advance

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Aug 2014, 03:56 AM
Hi Yazid,

In order to achieve your scenario one suggestion is try to attach the OnClientItemChecking event of RadComboBox and try the below JavaScript.

function selectAll(sender, args) {
    var index, count;
    count = sender.get_items().get_count();
    if (args._item._text == "Select All") {
        for (index = 1; index < count; index++) {
            sender.get_items()._array[index].check();
        }
        args.set_cancel(true);
        sender.set_text("All");
    }
}

Another suggestion is that you can upgrade the Telerik version and  change the "Check All" string value using the RadComboBox Localization. Please take a look into this online demo.

Thanks,
Princy.

0
Yazid
Top achievements
Rank 1
answered on 13 Aug 2014, 11:10 AM
Hi Princy,
thank you for the answer. 
Unfortunatly, OnClientItemChecking  will not work because the Text will be set later after all CheckBoxes have been selected.
Telerik upgrade can't be performed at moment because it will affect the whole application framework. The appliication and application 
framework are comprised of many hundred of thousand code lines at least.

But I found out  by using a reflectorthat the iput field is rendered in a method named,,RenderTable" wich is rendered
in the RenderContents-method.

So I can override the RenderContents-method to achieve the desired result.

Anaway thank you very much.

Rrgards
Tags
ComboBox
Asked by
Yazid
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Yazid
Top achievements
Rank 1
Share this question
or