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

[Solved] LoadOnDemand post processing question

1 Answer 130 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
John Fetherolf
Top achievements
Rank 1
John Fetherolf asked on 19 Jun 2008, 08:25 PM
I have a LoadOnDemand combobox that I want to limit to 25 items or less.  I can do this just fine.  However I also want to update a label on the page with a match count depending on the contents of the text in the control.  I can probably show this better with an example:

Combo Text                       Label  
----------                       -----  
AL1                              4500 match(s)  
AL12                             567 match(s)  
AL123                            120 match(s)  
AL1234                           18 matche(s)       // actual items appear here. 

So far the load on demand portion of this is working fine.  However I can't figure out a way to pass back the match count (4500, 567, 120, 18, etc...) to the client so that the label can be updated.  I tried AjaxManager.ResponseScripts.Add() with no luck.  Also investigated the OnClientItemsRequested property, but there doesn't seem to be a way to pass a value back to it from the server call.

Is there any way to do what I am trying to do here?  Any help would this would be, as usual, greatly appreciated.

Thanks,
Kevin

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 23 Jun 2008, 01:11 PM
Hello John Fetherolf,

You could use the following approach:
  • Insert a 'helper' Item at index 0 in the ItemsRequested event handler with value/text set to the number of matches.
  • In the OnClientItemsRequested event handler do something like this:
            function onClientItemsRequested(sender, eventArgs) 
            { 
                var helperItem = sender.get_items().getItem(0); 
                 
                sender.get_items().removeAt(0); 
                 
                var label = document.getElementById("matchesCount"); 
                 
                document.title = helperItem.get_value(); 
            } 
    In brief, get the first 'helper' Item, remove it from the Items collection, as it is not part of the results, and finally use its value/text to indicate the number of matches.

Generally, RadComboBox is not designed to return any additional information from the ItemsRequested event handler except when using the 'Show More Results' functionality.

Regards,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
John Fetherolf
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or