I am using a combobox with LoadOnDemand, and it is working nicely. I wanted to use the OnClientItemsRequesting event to prevent the combobox loading until the user types in at least three characters.
function OnClientItemsRequesting(sender ,eventArqs)When I debug this, it appears to be working. It reads in the characters that have been typed in, and if its less than 3, it goes to the return false statement. However, the server event is still being fired and the combobox is being populated.
{
var textvalue = sender._inputDomElement.value;
if(textvalue.length < 3)
{
return false
}
}
Is there something else / somethig different I need to be doing to make this work?
Martin
5 Answers, 1 is accepted
Since you are working with the "Prometheus" version of the RadComboBox control, you can cancel the event by using the cancel property of the eventArgs passed to the handler this way:
function OnClientItemsRequesting(sender, eventArgs) |
{ |
var textvalue = sender._inputDomElement.value; |
if (textvalue.length < 3) |
{ |
eventArgs.set_cancel(true); |
} |
} |
I've attached a small demo project where you can test it.
All the best,
Simeon
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thanks very much.
Im getting
Microsoft JScript runtime error: Object doesn't support this property or method
On the
eventArgs.set_cancel(
true);
Any Ideas?
Jeff
Please make sure that you are using the Prometheus (Web.UI) edition instead of the classic combobox. If this is not the case, could you please paste here the code of the problematic js function along with the aspx declaration of the combobox.
Regards,
Nick
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I just created a new page and copy and pasted the code over and it seems to be working now. Another VS2008 feature i guess.
Thanks for your time anyway.
Thanks Nick.
<%
@ Register assembly="Telerik.Web.UI, Version=2007.3.1314.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<
telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</
telerik:RadScriptManager>
<script type="text/javascript" language="javascript">
function OnClientItemsRequesting(sender, eventArgs)
{
var textvalue = sender._inputDomElement.value;
if (textvalue.length < 3)
{
eventArgs.set_cancel(
true);
}
}
</script>
<
Telerik:RadComboBox ID="ddlUsers" runat="server" EnableLoadOnDemand="True" Skin="Office2007" Width="350px" DropDownWidth="500px" ShowMoreResultsBox="True" RadComboBoxImagePosition="Right" onclientitemsrequested="OnClientItemsRequesting">
<
CollapseAnimation Duration="200" Type="OutQuint"></CollapseAnimation>
<
ExpandAnimation Type="OutQuart"></ExpandAnimation></Telerik:RadComboBox>