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

OnClientItemsRequesting not cancelling server event

5 Answers 137 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 2
Martin asked on 10 Jan 2008, 01:33 PM
Hello,

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)
        {
            var textvalue = sender._inputDomElement.value;
            if(textvalue.length < 3)
            {
                return false
            }
        }
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.

Is there something else / somethig different I need to be doing to make this work?

Martin

5 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 11 Jan 2008, 09:27 AM
Hi Martin,

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
0
Martin
Top achievements
Rank 2
answered on 11 Jan 2008, 09:43 AM
Yes, that worked.

Thanks very much.
0
Jeff
Top achievements
Rank 1
answered on 19 Feb 2008, 03:59 AM
Hello.

Im getting

Microsoft JScript runtime error: Object doesn't support this property or method

On the

eventArgs.set_cancel(

true);

Any Ideas?

Jeff

0
Nikolay
Telerik team
answered on 19 Feb 2008, 08:08 AM
Hello 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
0
Jeff
Top achievements
Rank 1
answered on 19 Feb 2008, 10:03 PM

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>

Tags
ComboBox
Asked by
Martin
Top achievements
Rank 2
Answers by
Simon
Telerik team
Martin
Top achievements
Rank 2
Jeff
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or