
How can I set RadAutoCompleteBox readonly. I can not find which function support that.
Thank you very much.
26 Answers, 1 is accepted

I am not clear with your requirement. The RadAutoCompleteBox does not have a Read Only property. Suppose if you want to prevent editing the token you can set the AllowTokenEditing property to false. Please have a look at the following mark-up.
ASPX:
<
telerik:RadAutoCompleteBox
ID
=
"RadAutoCompleteBox1"
runat
=
"server"
EmptyMessage
=
"Enter Name"
InputType
=
"Token"
DataSourceID
=
"SqlDataSource2"
DataTextField
=
"ContactName"
>
<
TokensSettings
AllowTokenEditing
=
"false"
/>
</
telerik:RadAutoCompleteBox
>
Thanks,
Princy.

I used RadAutoCompleteBox instead of RadTextBox because I want to show my recipients list in token and I don't allow user type in RadAutoCompleteBox directly. Users have to use other tool to find recipients.
I can suggest you, to disable the RadAutoCompleteBox, since you want to prevent the end user to add, edit or delete entries. You could use the Enabled property set to False.
Please note that with the usage of the aforementioned property, the appearance of the control would be slightly changed. If you want to persist the standard rendering, I can suggest you to use the property and remove the applied css class (racDisabled) with jquery in the following manner :
<script>
function
pageLoad() {
$telerik.$(
".racTokenList"
).removeClass(
"racDisabled"
);
}
</script>
Kind regards,
Nencho
the Telerik team

Thank you for support me, It goes perfectly. But I still have one concern, Is it possible to delete token when we set RadAutoCompleteBox's properties to false. As I saw It is impossible.
As you well guessed - it is impossible to delete any token when the suggested approach is implemented. Therefor, I can suggest you a slightly different approach. You could disable only the input area of the RadAutoCompleteBox using jquery and the
OnClientLoad
client-side event of the control . Thus you could persist the ability to delete the entries. Consider the following implementation:<script type=
"text/javascript"
>
function
OnClientLoad(sender) {
$telerik.$(
".racInput"
).attr(
"disabled"
,
"disabled"
);
}
</script>
Greetings,
Nencho
the Telerik team

Autocompletebox may not be the most suitable control for a token container, but until such time as RadList has a "token" mode it is the only option.
You could use the set_enabled(bool value) client-side method of the RadAutoCompleteBox, in order to manage its Enabled state.
Regards,
Nencho
Telerik

I was able to replicate the described issue and it originates from the implementation of the previously provided custom approach. Therefore, I had forwarded your suggestion about managing the Enabled state only of the input of the control, by a property.
Regards,
Nencho
Telerik

Your suggestion is really valuable. I have to inform you, that we had already considered a possible implementation regarding this scenario and the inability of the user to click on the X button, when the Token is wider then the AutoCompleteBox. However, we deiced to implement a slight different approach : restrict the Width of any Token, which is lager then the AutoComplete to have equal width to the Control. In addition, the text which remains invisible will be replaced by tree dots.
Regards,
Nencho
Telerik

Your observations are absolutely correct. The feature is not yet implemented. The status of the feature is under implementation and you could use our release history here, in order to track the release of the feature.
Regards,
Nencho
Telerik

I would like to clarify that at this moment we are not able to provide you a specific release or a time span when this feature will be implemented. However you can review our road map that contains information about what is coming in the upcoming release or the release history that shows what was fixed and implemented in each release.
Please do not hesitate to contact us if you have any further questions.
Regards,
Boyan Dimitrov
Telerik

Indeed the feature is not yet implemented, this is why I had increased its priority. However, I would like to suggest you a custom implementation, which would fit the requirements of the previously mentioned feature with the three dots at the end of the token, if it exceeds the width of the control. Please find a sample page attached, where a couple of css style rules are used to achieve the needed behavior.
Regards,
Nencho
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Is it possible to have
$telerik.$(
".racTokenList"
).removeClass(
"racDisabled"
);
for a specific RadAutoCompleteBox instead of all of them?
Yes, you can achieve the desired functionality by simple modification of the selector, regarding the ID of the RadAutoCompleteBox on which you need to apply the removeClass method:
$telerik.$(
"#RadAutoCompleteBox1 .racTokenList"
).removeClass(
"racDisabled"
);
Regards,
Nencho
Telerik

Hi, I know this is old but could be still usefull, to make it RO use client side OnEntryRemoving function like this:
function RACB_MyControl_EntryRemoving(sender,args)
{
args.set_cancel(true);
}
Indeed with the demonstrated approach you will disable the end user from the ability to remove any of the added entries. However, the ability to add new entries still persist. In addition, the visual indication (grey color) will also miss.
However, thank you for sharing your approach with the community.
Regards,
Nencho
Telerik

Hello,
I would like to ask, why RadAutoCompleteBox control doesn't have same CSS styles classes as RadTexbox or RadNumericTextBox ? I mean something like this:
<EnabledStyle CssClass="MyEnabledTextBox" />
<ReadOnlyStyle CssClass="MyReadOnlyTextBox" />
<DisabledStyle CssClass="MyDisabledTextBox" />
<EmptyMessageStyle CssClass="MyEmptyTextBox" />
<FocusedStyle CssClass="MyFocusedTextBox" />
<HoveredStyle CssClass="MyHoveredTextBox" />
<InvalidStyle CssClass="MyInvalidTextBox" />
<ClientEvents OnValueChanged="txt_zakazka_ValueChanged" OnKeyPress="OnKeyPress" />
Question is, how to overcome this issue and apply need classess ?
Best regards
Vasssek
Hi Vasssek,
The autocomplete does not have all of those states and features to begin with, because it has a different purpose.
Setting a CssClass to the control and cascading through it will let you modify the hovered state for example. You can inspect the rendered HTML with the browser dev toolbar to see what classes are added to what elements in order to use them in the cascade.
Here is a basic example:
/*racTokenList is the contianer of the control without the popup*/
.myCustomAppearance .racTokenList {
border
:
2px
solid
blue
;
}
/*the .racHovered class is added by the control with JS when it is hovered, othewise you can use the :hover pseudoselector if you like*/
.myCustomAppearance .racHovered {
border
:
2px
solid
red
;
}
/*racDisabled is added when the Enabled property is set to false*/
.myCustomAppearance .racDisabled {
border
:
2px
solid
green
;
}
.myCustomAppearance .racFocused {
border
:
2px
solid
magenta;
}
</style>
<telerik:RadAutoCompleteBox runat=
"server"
ID=
"rau1"
CssClass=
"myCustomAppearance"
></telerik:RadAutoCompleteBox>
<telerik:RadAutoCompleteBox runat=
"server"
ID=
"rau2"
></telerik:RadAutoCompleteBox>
Regards, Marin Bratanov
Progress Telerik

Hi albert
I am using RadAutoCompleteBox. when i type 3 letters on that textbox it will start searching for that email/Name. My issue was when request has went to the server then immediately i am removing those 3 letters and i am entering another 3 letters. at the end my dropdown is loding with first search result set (whatever i have searched for the first time). But i need latest dropdown values which ever i requested for second time.
kindly help me on this.


It seems there is a mix of issues and desires in this thread. For those who initially wanted to use the AutoCompleteBox as a token container where the adds are performed programmatically and want to maintain the functionality of being able to click the x on the token to remove (no disable needed) use this CSS to keep user from typing in box:
<style>
div.RadAutoCompleteBox .racInput {
visibility: hidden
}
</style>