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

[Solved] Items still disabled after calling enable()

6 Answers 141 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ian Mac
Top achievements
Rank 1
Ian Mac asked on 28 Apr 2009, 02:57 PM
Hi

I have a multiselect RadComboBox with a checkbox in the itemtemplate. The control is initially disabled but when I enable it the items stay disabled. Here is the code:-

function toggleFPs(chk)
{
var combo = $find("<%= cmbFPs.ClientID %>");
if (chk.checked)
combo.disable();
else
combo.enable();
}
...
<telerik:RadComboBox ID="cmbFPs" runat="server" Height="160px" Width="185px" 
Enabled="false" HighlightTemplatedItems="true" 
DataTextField="Username" DataValueField="UserID" 
OnClientLoad="selChange"
OnClientSelectedIndexChanged="selChange" 
EmptyMessage="Choose Finance partners">
<ItemTemplate>
<asp:CheckBox runat="server" ID="CheckBox" DataValueField="UserID" onclick="event.cancelBubble=true;" Text="" />
<%# Eval( "UserName") %>
</ItemTemplate>
</telerik:RadComboBox>
<asp:CheckBox ID="chkAllFPs" runat="server" Text=" All " Checked="true"
onclick="toggleFPs(this)" />
...

How do I enable the checkbox in the items? 

I also tried this and still couldnt check the boxes...

  var items = combo.get_items();
for (var i = 0; i < items.get_count(); i++) 
items.getItem(i).enable();

I am using ASP.NET Ajax Q2 2008.

Thanks.

6 Answers, 1 is accepted

Sort by
0
Saed
Top achievements
Rank 1
answered on 04 May 2009, 09:07 AM
Ditto here. I ran into something similar today...

I disable the CB in JS and enable it via code-behind. When enabled, only InputArea changes style but ALL items remain dimmed and unselectable!

JS:
...
catCombo = $find("<%= rcb_CodeCat.ClientID %>");
var codeCat = catCombo.findItemByValue("some value");
catCombo.trackChanges();
catCombo.enable();     // MUST do in order to facilitate item selection
codeCat.select();
catCombo.disable();
catCombo.commitChanges();
...

VB.NET
...
rcb_CodeCat.Enabled = True
rcb_CodeCat.EnableTextSelection = True
...

Something else I noticed:
If CB is disabled, I cannot alter item selection, whether clearing current selection or setting another item as selected. Must enable it first as can be seen in the JS snippet above.

Am I missing something here?

Regards,


0
Saed
Top achievements
Rank 1
answered on 04 May 2009, 09:13 AM
Forgot to clarify that before using JS, changing selected item was applicable in code-behind, even if the CB was disabled. The instance occurs when CB is disabled via JS then enabled from code-behind.

Regards,
0
Atanas Korchev
Telerik team
answered on 05 May 2009, 01:41 PM
Hello Saed,

We are not sure how to reproduce the problem. I suggest you open a support ticket and send us a sample page which shows the issue. Thanks.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ian Mac
Top achievements
Rank 1
answered on 07 May 2009, 01:12 PM
Solved it by explicitly enabling each checkbox AND the parent SPAN, by changing to the following routine:-

        function toggleFPs(chk) 
        { 
            var combo = $find("<%= cmbFPs.ClientID %>"); 
            if (chk.checked) 
                combo.disable(); 
            else 
                combo.enable(); 
 
            // Enable items 
            var chkboxId, chkbox; 
            var items = combo.get_items(); 
            for (var i = 0; i < items.get_count(); i++)  
            { 
                items.getItem(i).enable(); 
 
                chkboxId = "<%= cmbFPs.ClientID %>" + "_i" + i + "_CheckBox"; 
                chkbox = document.getElementById( chkboxId); 
 
                chkbox.disabled = false
                chkbox.parentNode.disabled = false
            } 
        } 


0
Saed
Top achievements
Rank 1
answered on 09 May 2009, 12:42 AM
A functional workaround might be, but not practical IMHO.

Why to walk every Combo item in order to alter its status? Logically, when Enabling/Disabling the Parent (the ComboBox in this case), children should inherit and affected accordingly?! Unless, there is something I'm missing here...

As for my case, I dropped the code-behind approach, and shifted the task to client-side. So, my Combo is now enabled/disabled via client-side, which sounds fine so far.

Regards,
0
Simon
Telerik team
answered on 11 May 2009, 03:31 PM
Hi Saed,

I logged the bug with the disabled Item in our bug-tracking system and updated your Telerik points for reporting it.

Thank you for your involvement in the matter.

Regards,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
Ian Mac
Top achievements
Rank 1
Answers by
Saed
Top achievements
Rank 1
Atanas Korchev
Telerik team
Ian Mac
Top achievements
Rank 1
Simon
Telerik team
Share this question
or