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

[Solved] ItemsRequested event not fired when there is one item in the combo box

4 Answers 180 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ivo
Top achievements
Rank 1
Ivo asked on 10 Mar 2008, 12:19 PM
Hello,
I am using Rad combo box control and I want to populate it, initially, with only one default option and upon clicking on the drop-arrow image to populate the remaining items. However, it looks like the ItemsRequested event is not fired when there is one item in the combo box (the event is fired when there aren’t any items in the control).
Is there a way to get this event fired in my scenario?

Thanks,
Ivo

4 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 10 Mar 2008, 12:43 PM
Hello Ivo,

You can do the following to accomplish the task.

Hook on the Sys.Application.load event, like:

<script>
  function pageLoad()
  {
      var combo = $find("<%=RadComboBox1.ClientID%>");
      //get the image DOM element and wire its click event
      var imageDOM = combo.get_imageDomElement();
      imageDOM.onclick = function(){ var combo = $find("<%=RadComboBox1.ClientID%>"); combo.RequestItems();}
     
  }

</script>

Hope this helps.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ivo
Top achievements
Rank 1
answered on 10 Mar 2008, 01:19 PM
Hi Nik,
Thank you for the quick response.
I tried the code, but I got object not supported JavaScript error on combo.RequestItems() call.

Thanks,
Ivo
0
Accepted
Veselin Vasilev
Telerik team
answered on 10 Mar 2008, 04:04 PM
Hi Ivo,

The correct syntax is this:

function pageLoad()  
{  
      var combo = $find("<%=RadComboBox1.ClientID%>");  
      //get the image DOM element and wire its click event  
      var imageDOM = combo.get_imageDomElement();  
      imageDOM.onclick = function(){ var combo = $find("<%=RadComboBox1.ClientID%>");  
      combo.requestItems(""false);}        

You can use another approach also:

Hook on the OnClientDropDownOpening event and invoke the requestItems method there.

function onDropDownOpening(sender, eventArgs)  
{  
    sender.requestItems(""false);  

I hope this helps.

Regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ivo
Top achievements
Rank 1
answered on 11 Mar 2008, 02:36 AM
Works perfect!
Thanks a lot!
Tags
ComboBox
Asked by
Ivo
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Ivo
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or