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

Can't set Text with Checkboxes, AllowCustomText and LoadOnDemand true

3 Answers 79 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 26 Aug 2011, 09:03 PM

What I have set up is a RadComboBox with:

            AllowCustomText = true

            CheckBoxes = true

            EnableLoadOnDemand = true

            OnItemsRequested = MyFunctionToGetColumns
            Text="PreviouslySavedText"

Everything works as expected, except the input isn't filled with the Text value.
My workaround for now is to set the EmptyMessage to the PreviouslySavedText.  Is there a better way to set the text on load?


3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Aug 2011, 09:03 AM
Hello Scott,

I tried the same scenario and it is working as expected in this version 2011, 1, 315, 35. I suppose this is a version issue. Make sure that you use latest version. Try upgrading to latest version with the help of the following help documentation.
Upgrading RadControls Trial to RadControls Developer license or newer version.

Thanks,
Shinu.
0
Scott
Top achievements
Rank 1
answered on 29 Aug 2011, 03:59 PM
Hi Shinu,
Thanks for the quick reply.  I'm using version 2011.2.712.35.  Could this have been introduced in the newer version?
-Scott
0
Thad
Top achievements
Rank 2
answered on 29 Aug 2011, 11:06 PM
Hi Scott,

This is indeed an issue in 2011, Q2.  When using checkboxes, the Text property becomes read-only.  See this post for confirmation:
http://www.telerik.com/community/forums/aspnet-ajax/combobox/setting-text-via-javascript-when-checkboxes-true.aspx

Possible workaround.  I noticed that if you bind the RadComboBox using JavaScript, you can set the text property...  Maybe this will help for you? 

function bindRadComboBoxToJSON(radComboBoxId, jsonData) {
    var comboBox = $find($('.RadComboBox[id$="_' + radComboBoxId + '"]').attr('id'));
 
    if (comboBox) {
        comboBox.trackChanges();
        comboBox.clearItems();
        for (var i = 0; i < jsonData.length; i++) {
            var newItem = new Telerik.Web.UI.RadComboBoxItem();
            newItem.set_text(jsonData[i].text);
            newItem.set_value(jsonData[i].value);
            newItem.set_checked(true);
            comboBox.get_items().add(newItem);
        }
        comboBox.set_text('some default text'); // <---- set text here
        comboBox.commitChanges();
    }
}

Please note that the above code reveals another bug.  Adding items that are checked to the RadComboBox  using JavaScript does not automatically set the Text property like it does when binding on the server.  Shouldn't bother you in your situation, but this bug has been reported to Telerik for verification anyway.

Hopefully they fix this in future releases.
-Thad
Tags
ComboBox
Asked by
Scott
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Scott
Top achievements
Rank 1
Thad
Top achievements
Rank 2
Share this question
or