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

LoadOnDemand and ShowMoreResults

1 Answer 47 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
co-logic
Top achievements
Rank 1
co-logic asked on 05 Feb 2009, 03:29 PM
Hi,
I implemented your LoadOnDemand demo project in my current project. It works fine for a small set of results. But due to the client side script "OnClientItemsRequesting" the demo fetches ALL results (search string is set empty!) when scrolling down to the next results. You can't see it in the demo, because there are less than 10 similar records searchable.

In my project I use a client side variable to save the last typed text:

<script type="text/javascript"
    var typedText = ""
     
    function OnClientItemsRequesting(sender, e) { 
        var context = e.get_context(); 
        if (!sender.get_appendItems()) typedText = e.get_text(); 
        context["FilterString"] = typedText; 
    } 
</script> 

Now I want to enable this code for multiple ComboBoxes. Is there an easy way to save the variable typedText with a single ComboBox?

Or more simple: Is there a way to get the last user-typed-text? If I use e.get_text() even if get_appendItems is true, the first marked text is returned and not the user typed search text.

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 09 Feb 2009, 05:06 PM
Hello co-logic,

You can disable the MarkFirstMatch functionality and use get_text regardless of the value returned by get_appendItems() method.

Alternatively you could handle the OnKeyPressing event and store the entered text in a global variable. In case you use one event handler for all ComboBoxes, the global variable could be an object used as a hashtable where the keys would be the Client Ids of the ComboBoxes.

Regards,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
co-logic
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or