How can i set Readonly property for RadCombobox ?
e.g. RadComboBox.Readonly = true, something like that ??
best regards
http://www.sport-events.ch
27 Answers, 1 is accepted
RadComboBox will be in ReadOnly mode(the user will not be able to enter text, only to select one of the items) if
AllowCustomText ,MarkFirstMatch and EnableLoadOnDemand properties are set to false.
Try it and let us known how this goes.
Regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
i have an WebUserControl. Inside of them is RadCombobox with EnableLoadOnDemand feature.
Now, i'm using my webusercontrol in an other form. There i will be set the text directly, without allow the user to select the radcombobox.
public void fillControl(string primaryKey)
{
radcombobox1.text = "test";
radcombobox1.enableloadondemand = false;
}
when i make this, i can't see the test text !!
I wish to desable the loadondemand. i will set only the text = "test".
You can try the following approach:
<script type="text/javascript">
function pageLoad()
{
var combo = $find('<%=RadComboBox1.ClientID%>');
combo.set_text("test");
}
</script>
Regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
RadComboBox does not support readonly mode. You can however try disabling it.
Regards,
Albert
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please find below a sample code snippet that shows the needed approach.
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title></title> |
<style type="text/css"> |
.RadComboBox_Outlook .rcbDisabled td.rcbInputCellLeft |
{ |
background-image: none !important; |
background-color: InactiveBorder; |
} |
</style> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
</telerik:RadScriptManager> |
<telerik:RadComboBox ID="RadComboBox1" runat="server" Skin="Outlook" Enabled="false"> |
<Items> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" Value="RadComboBoxItem2" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" Value="RadComboBoxItem3" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem4" Value="RadComboBoxItem4" /> |
</Items> |
</telerik:RadComboBox> |
<asp:TextBox runat="server" Enabled="false">tetete</asp:TextBox> |
</form> |
</body> |
</html> |
Best wishes,
Paul
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.
.RadComboBox_Vista
.rcbDisabled
{
filter: none !important;
opacity: 1 !important;
color: Red;
}
but I cannot change the text color. Can I change the color of the disabled text?
Thanks.
Here's a sample code snippet that shows the needed approach.
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title></title> |
<style type="text/css"> |
.RadComboBox_Vista .rcbDisabled .rcbInputCell .rcbInput, |
.RadComboBoxDropDown_Vista .rcbDisabled |
{ |
filter: none !important; |
opacity: 1 !important; |
color: Red !important; |
} |
</style> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
</telerik:RadScriptManager> |
<telerik:RadComboBox runat="server" ID="RadComboBox1" Skin="Vista"> |
<Items> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="RadComboBoxItem1" |
Enabled="false" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" Value="RadComboBoxItem2" |
Enabled="false" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" Value="RadComboBoxItem3" /> |
</Items> |
</telerik:RadComboBox> |
</form> |
</body> |
</html> |
Greetings,
Paul
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I highly recommend to have the functionality implemented due to demand. You know it is extremely easy to add such a functionality.
In a meanwhile the work around is to have RadTextBox, which does have ReadOnly functionality, replacing the RadComboBox when you need it to show as read only. Of course you have to also manage the visibility of those two by toggling based on the need.
Since the read-only state of RadComboBox depends on various different behaviors (allowing custom text, client-side highlighting, Load On Demand) introducing yet another property will add only unnecessary confusion.
Currently, RadComboBox is read-only by default. Setting any of the AllowCustomText, MarkFirstMatch, Enable(Automatic)LoadOnDemand to true will disable this.
Best wishes,
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
.Style = "margin-top:-1px;margin-bottom:-1px"
I tried to set additional properties but they do not affect it.
.EnableEmbeddedSkins = False
.EnableEmbeddedBaseStylesheet = False
.DropDownCssClass = String.Empty
Private Sub DisableRadCombobox(ByVal cntrl As RadComboBox) |
With cntrl |
.ShowToggleImage = False |
.AllowCustomText = False |
.MarkFirstMatch = False |
.EnableTextSelection = False |
.EnableLoadOnDemand = False |
.BackColor = Drawing.Color.Gainsboro |
'.ForeColor = Drawing.Color.Black 'This doesn't do anything for IE |
.ShowDropDownOnTextboxClick = False |
.Skin = String.Empty 'important |
.AutoPostBack = False |
'.Enabled = False 'Note: due to RadComboBox's rendering for disabled we left it enabled with selected item only |
Dim tmpItem As RadComboBoxItem = .SelectedItem |
.Items.Clear() |
If tmpItem IsNot Nothing Then |
.Items.Clear() |
.Items.Add(tmpItem) |
tmpItem.Selected = True |
End If |
End With |
End Sub |
Can you please provide more information about this issue, perhaps a screenshot? Please also note the version of the browser in which it occurs.
Regards,
Simon
the Telerik team
See the extra white line between the border and the input that the arrow is pointing to.
Thank you for the screenshot.
So I tried reproducing this with the latest version of Telerik.Web.UI and this RadComboBox:
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
BackColor
=
"Gainsboro"
ShowDropDownOnTextboxClick
=
"false"
Skin
=
""
>
</
telerik:RadComboBox
>
without success.
What I see is the same as the first RCB in your screenshot.
Please let me know the exact version of the Telerik.Web.UI assembly that you use as it may be older and having the bug (which we probably have fixed later).
Best wishes,
Simon
the Telerik team
In this case, we may have to provide you with a workaround for the version you are using.
Please open a support ticket and send us a project (including the dll), which shows the issue.
Kind regards,
Simon
the Telerik team
How can i set Readonly property for RadCombobox ?
radComboBox.ShowDropDownOnTextboxClick =
false
;
radComboBox.ShowToggleImage =
false
;
foreach
(RadComboBoxItem radComboBoxItem
in
radComboBox.Items)
{
radComboBoxItem.Enabled =
false
;
}
Assuming you have radComboBox being your control. This is not optimal but it works fine if you don't want to mess with additional text box controls.
After reconsidering the possibility of adding the ReadOnly property we came up with a solution you can use now to achieve the required state. You can handle the client-side Load event of the RadComboBox in this way:
function
onLoad(sender) {
var
input = sender.get_inputDomElement();
input.readOnly =
true
;
$telerik.$(input).keydown(
function
(e) {
return
false
; });
sender.add_dropDownOpening(
function
(s, e) { e.set_cancel(
true
); });
}
I hope this helps.
Kind regards,
Simon
the Telerik team
Can you tell me how can I fix it?
Well, the drop down gets enabled but the keydown part didn't.
here's my code:
function
setRadComboBoxReadOnly(sender, isReadOnly) {
var
input;
if
(isReadOnly) {
input = sender.get_inputDomElement();
input.readOnly =
true
;
window.$telerik.$(input).keydown(
function
(e) {
return
false
; });
sender.add_dropDownOpening(
function
(s, e) { e.set_cancel(
true
); });
}
else
{
input = sender.get_inputDomElement();
input.readOnly =
false
;
window.$telerik.$(input).keydown(
function
(e) {
return
true
; });
sender.add_dropDownOpening(
function
(s, e) { e.set_cancel(
false
); });
}
}
In this way you are attaching another keydown event to the input and the old one remains. I suggest you use namespaced events to attach keydown and remove it instead of adding a new handler when you want to restore RadComboBox's state.
Kind regards,
Simon
the Telerik team
/// <summary>
/// Makes page readonly
/// </summary>
private
void
MakeReadOnly()
{
btnSubmit.Visible =
false
;
btnAutoFill.Visible =
false
;
sdDocuments.DisableDelete =
true
;
btnScan.DisableScanning =
true
;
foreach
(Control Ctrl
in
Controls) {
if
(Ctrl.GetType().ToString().Equals(
"System.Web.UI.WebControls.TextBox"
))
((TextBox)Ctrl).ReadOnly =
true
;
if
(Ctrl.GetType().ToString().Equals(
"Telerik.Web.UI.RadComboBox"
))
((RadComboBox)Ctrl).AllowCustomText = ((RadComboBox)Ctrl).MarkFirstMatch = ((RadComboBox)Ctrl).EnableLoadOnDemand = ((RadComboBox)Ctrl).ShowDropDownOnTextboxClick = ((RadComboBox)Ctrl).EnableAutomaticLoadOnDemand =
false
;
}
}
//End private void MakeReadOnly(...
The ReadOnly state of the RadComboBox has a bit different signification. The control is in ReadOnly state, when the AllowCustomText property is set to false. In other words, when custom text is not allowed to be entered in the control. Therefore, you could manage the Enabled property of the control, in order to achieve the desired functionality.
Regards,
Nencho
Telerik
Hi telerik
I have a question; I am using a radcombobox, I setup the "markFirstMatch" as true but it has the following behavior:
1.If you click over the button with the arrow the options list is shown and the cursor is positioned at the beginning of the selected item text.
2. Then if you hit a click over the selected item area (not in the button with the arrow) the text on this area is highlighted and the options list is shown.
3. Now if you click again over the button with the arrow, you will see that the text on the selected item area is highlighted that is not the same behavior from the step one.
My question is, is this a normal behavior? or it is a way if you click over the selected item area o radcombobox button the text is highlighted? we have the "Marckfirstmatch" property set to true as the user types the initial letters of the option he wants to select, the list of options changes and is positioned over the one that matches what the user is typing; But if we put the property in false, the list of options only takes into account the first letter and is positioned on the first option that finds with that letter.
In other words, it is possible to have " markfirstmatch="true" " and also select the text of selected item if you click over the selected item area or in the button.
I'm using the following code for the radcombobox.
<telerik:RadComboBox
ID="idxCLIENTID"
Width="270px"
MarkFirstMatch="true"
AllowCustomText="false"
runat="server"
RenderMode="Lightweight"
CausesValidation="False"
AutoPostBack="True">
<Items>
<telerik:RadComboBoxItem runat="server" Text="ANY" Value="ANY" />
<telerik:RadComboBoxItem runat="server" Text="all" Value="all" />
<telerik:RadComboBoxItem runat="server" Text="alvaro" Value="alvaro" />
<telerik:RadComboBoxItem runat="server" Text="juan" Value="juan" />
<telerik:RadComboBoxItem runat="server" Text="carlos" Value="carlos" />
<telerik:RadComboBoxItem runat="server" Text="allan" Value="allan" />
<telerik:RadComboBoxItem runat="server" Text="carla" Value="carla" />
<telerik:RadComboBoxItem runat="server" Text="julia" Value="julia" />
<telerik:RadComboBoxItem runat="server" Text="Martha" Value="Martha" />
<telerik:RadComboBoxItem runat="server" Text="alicia" Value="alicia" />
<telerik:RadComboBoxItem runat="server" Text="mauricio" Value="mauricio" />
</Items>
</telerik:RadComboBox>
Thanks.