Hi All,
In the new 2011 Q2 controls the Checkbox in RadCombo is introduced.
I'm adding Items to the Control by Code, Always Select the first one, which cant be deselected
So on the Item_created i do the following:
if e.item.index = 0 then
e.item.checked = true
e.item.enabled = false
endif
which results in a greyed out Text, but still enabled Checkbox.
See attached picture
Kind regards Marco
3 Answers, 1 is accepted
I created a test page I tried to reproduce the issue that you describe, but without success.
Please take a look at the code that I've used (I suppose that there is something different in your page that causes the issue):
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
CheckBoxes
=
"true"
>
</
telerik:RadComboBox
>
</
div
>
</
form
>
</
body
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
this
.RadComboBox1.Items.Add(
new
RadComboBoxItem(
"Session 1"
,
"1"
));
this
.RadComboBox1.Items.Add(
new
RadComboBoxItem(
"Session 2"
,
"2"
));
}
}
Could you please provide us more details about your implementation and paste here a simplified working code that represents it?
How do you populate the RadComboBox with items?
Best wishes,
Kalina
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
I updated your example to the following:
asxp:
<
form
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
CheckBoxes
=
"true"
>
</
telerik:RadComboBox
>
</
form
>
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
Me
.RadComboBox1.Items.Add(
New
RadComboBoxItem(
"Session 1"
,
"1"
))
Me
.RadComboBox1.Items.Add(
New
RadComboBoxItem(
"Session 2"
,
"2"
))
End
Sub
Protected
Sub
RadComboBox1_ItemCreated(sender
As
Object
, e
As
Telerik.Web.UI.RadComboBoxItemEventArgs)
Handles
RadComboBox1.ItemCreated
If
e.Item.Index = 0
Then
e.Item.Checked =
True
e.Item.Enabled =
False
End
If
End
Sub
In the ItemCreated event I make the first in the list Checked = true and Enabled = false
The text is disabled but the checkbox is not, I can still change the checkbox
I assume that the checkbox also has to be disabled or do I miss something else to disable the checkbox of that item?
hopes this helps
Best regards Marco
Thank you for providing me a clear test case of the issue.
I successfully reproduced it and it looks like a bug - so we will research it and log it for fixing.
Let me suggest you overcome the issue by disable the RadComboBox item at client-side in this manner:
<
head
runat
=
"server"
>
<
title
></
title
>
<
script
type
=
"text/javascript"
>
function OnClientLoad(sender) {
// disable the first item :
sender.get_items().getItem(0).disable();
}
</
script
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
OnItemCreated
=
"RadComboBox1_ItemCreated"
OnClientLoad
=
"OnClientLoad"
CheckBoxes
=
"true"
>
</
telerik:RadComboBox
>
</
form
>
</
body
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
this
.RadComboBox1.Items.Add(
new
RadComboBoxItem(
"Session 1"
,
"1"
));
this
.RadComboBox1.Items.Add(
new
RadComboBoxItem(
"Session 2"
,
"2"
));
}
protected
void
RadComboBox1_ItemCreated(
object
sender, Telerik.Web.UI.RadComboBoxItemEventArgs e)
{
if
(e.Item.Index == 0)
{
e.Item.Checked =
true
;
// e.Item.Enabled = false;
}
}
You will not need this workaround once we fix the issue.
Thank you for taking your time to report this - please find your Telerik points updated.
Kind regards,
Kalina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.