AJAX Combobox Load-on-Demand with CustomText AND SelectedValue

14 posts, 0 answers
  1. Michael
    Michael avatar
    8 posts
    Member since:
    Nov 2007

    Posted 03 Mar 2009 Link to this post

    We have been trying to use a combination of features of the RadComboBox. We want to use Load-on-Demand with CustomText AND also set/persist a SelectedValue, with a large number of records. We have encountered a couple issues that prevent us from accomplishing our goal.

    The online demo ( http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx ) narrowly avoids one of the major issues we have encountered with the suggested implementation of load-on-demand. The online demo loads just enough records per request (10) that no matter what custom text is entered, there is never more than one request worth of filtered items to load. We often need multiple requests to load all of the matching/filtered items for the custom text, but the demonstrated method reverts to loading unfiltered items after the first request. We tried working around this issue ourselves, but then ran into another quirk of the load-on-demand mechanism.

    The demonstrated method seems to only be feasible in the context of a single pass questionaire. Our application requires users be able to view and edit previous selections in fields with load-on-demand enabled. We are able to set a selected value, but then load-on-demand breaks. Every time the user clicks the load more results button, another duplicate of the selected value is added to the list. We tried various workarounds without success. We cannot distinguish between the first request (showing the selected value) and subsequent requests (showing filtered or unfiltered items based on the custom text).

    We need to accomplish the following with the RadComboBox:

    1. Load-on-demand (we have very large lists of items to select from in our application)
    2. Custom text/filter (loading multiple pages of items isn't enough, we need to filter the list)
    3. Selected value (on returning to the page, the user needs to be able to see what they selected previously as well as select a new value)

     

    We are very close to having all three features working together, but are missing a piece. When the user opens the combobox, sees the selected value listed as the only item, and clicks the load more results button, we need to load unfiltered items instead of filtered items. We can always load the unfiltered items, but then we have the opposite problem: the custom text is never used to get a filtered list of items. This is the last obstacle to overcome in order to get load-on-demand working in our application the way it should (we think) by design.

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 06 Mar 2009 Link to this post

    Hello Michael,

    Briefly, Filtering and Load on Demand are two overlapping functionalities.

    Firstly, the Load on Demand filters the Items before they are loaded in the control by some criteria - in most cases Items which begin with the entered text are loaded. Then at the client, if Filter is enabled, the loaded Items will be filtered. In case of a Contains Filter for instance (and StartsWith is the same case) no Items are removed from the list as they are already matched upon the same criteria (at the server).

    In this sense, the only case that could be useful (and needs to be further implemented) is to have Contains Filter on a Load on Demand results set. This could be achieved by switching between the two functionalities of the RadComboBox control in a certain moment - checking/unchecking a CheckBox or pressing a combination of keys switches between Load on Demand and Filter.

    Please let me know if you are interested in this approach - I will prepare a simple example.

    Finally, regarding the issue with the duplicating Item - it is fixed and you could obtain the fix by downloading the latest internal build from your Client.net account and upgrading.

    Sincerely yours,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Michael
    Michael avatar
    8 posts
    Member since:
    Nov 2007

    Posted 06 Mar 2009 Link to this post

    Hi Simon,

    Thank you for looking into this. I'll take a look at the latest internal build.

    We use the RadComboBox inside several user controls. I was able to workaround the limitations of the RadComboBox using the client-side API. First, I dropped the original JavaScript from the demo. I also cached the previous text of the RadComboBox on every request except the first when not appending. When appending, I set the custom text to be the previous text.

    At this point, the items were correctly filtered or unfiltered in the situations I tested, but the counts were wrong. To fix the counts, I cached the original value of the RadComboBox only on the first request when not appending. Then, I compared the value of the first item to the original value and set a new context value to the NumberOfItems or the NumberOfItems-1, as appropriate. I changed the event handler to use the new context value instead of NumberOfItems.

    I set the text and value for the RadComboBox instead of the the SelectedValue property in the Page_PreRender of the user control. I also disable the MarkFirstMatch feature since it would select the first match using the text instead of the value when more than one item matched the text. So far, this implementation appears to work well in the situations that the demo did not.

    Looking at the resulting user experience, this is how I think the RadComboBox should work. Enabling load-on-demand should not adversely affect the fundamental behavior of a drop-down. The user expectation is to be able to view the list of items without the selected value changing. The selected value should only change when a discrete choice is made or when text is entered to filter the list of items. Similarly, requesting more items should be the same whether the list is filtered or unfiltered (i.e. more than one page of filtered items should be possible).

    I'm not sure how others are using these features in combination, but for us, displaying the previously selected value and enabling filtered load-on-demand should not only be possible together, but the combined behavior should be seamless for the user. The fact that I was able to hack together a workaround using the client-side API speaks highly of the robust feature set, however, a more elegant solution should be possible within the RadComboBox itself.
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 11 Mar 2009 Link to this post

    Hello Michael,

    Thank you for sharing your thoughts on the functionality of the RadComboBox control.

    The description you have provided is quite thorough however it would be easier to comprehend your approach if you provide the code as well.

    Could you open a formal support ticket and send us a page which shows the approach? In this way, we will be able to examine the code, test and assess it. If it is acceptable after that we will consider its integration in the code of the control.

    Greetings,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Michael
    Michael avatar
    8 posts
    Member since:
    Nov 2007

    Posted 11 Mar 2009 Link to this post

    Over the past few days I have refined the client-side API hacks that I am using. I will send a code sample to support as soon as I can put together a generic project to demonstrate it.
  6. Nelson
    Nelson avatar
    2 posts
    Member since:
    Apr 2010

    Posted 07 Apr 2010 Link to this post

    Hi, I have spent hours looking for a solution to the scenario that the TS has mentioned and still hasn't figured out the solution.

    I have a load-on-demand-enabled radcombobox on a data entry screen. At edit mode wherein the combo box has an existing value, upon clicking the combo, it only displays one item which is the match for current value. It will only display the complete list if I deleted the old value.

    What I want to happen is to prevent the filter from taking effect when the original text hasn't changed.

    Is there a workaround for this?
  7. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 08 Apr 2010 Link to this post

    Hi Nelson,

    You can handle the ItemsRequesting event in this way:
    function onRequesting(sender, eventArgs) {
        var context =  eventArgs.get_context();
        // If there are no Items currently in the RadComboBox...
        if (sender.get_items().get_count() == 0) // ...set the Text property of the Context object to an empty string.
            context["Text"] = "";
        else // Otherwise, set the Text property of the Context object to text currently in the input.
            context["Text"] = sender.get_text();
    }

    Then, in the server-side ItemsRequested you can use the Text property of the Context object ((string)e.Context["Text"]) and use it to filter the data.

    Please let me know whether this is helpful.

    All the best,
    Simon
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Nelson
    Nelson avatar
    2 posts
    Member since:
    Apr 2010

    Posted 08 Apr 2010 Link to this post

    Thanks Simon. Your solution did the trick the first time I hit the combo box. However, my load on demand combo displays 10 items at a time with enabled virtual scrolling. With this, once I tried to scroll down, the list won't be re-populated after the first 10 since the next call to itemsrequested will not clear the context["Text"] property. Is there another workaround for this?

    I hope you can also help me doing the same for combo box with multi-column and the EnableAutomaticOnDemand is enabled. The combo is bind to an object data source so even if I added an itemsrequested javascript and clear the context["Text"] property, it has no effect to the displayed list.

    Please note that I tried adding & removing the Filter property but that won't change the outcome.

    Thanks again,
    Nelson


  9. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 15 Apr 2010 Link to this post

    Hi Nelson,

    Actually there is an easier way to achieve the requirement stated in your first post, namely to stop the request for Items if the original Text hasn't changed.

    You can do this by first tracking the original (rendered) text in the RadComboBox' client-side object and then cancel the ItemsRequesting event if the text is the same, i.e.
    function onLoad(sender, eventArgs) {
        sender.originalText = sender.get_text();
    }
     
    function onItemsRequesting(sender, eventArgs) {
      eventArgs.set_cancel(sender.originalText == sender.get_text());
    }

    You can even use this approach with the 'automatic' RCB as well.

    Regards,
    Simon
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  10. EJ
    EJ avatar
    39 posts
    Member since:
    Jun 2012

    Posted 21 Jul 2010 Link to this post

    did you have a summary list or example of your loadondemand hacks? i'm having issues getting them to display previous selected values in a formview in edit mode
  11. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 27 Jul 2010 Link to this post

    Hello EJ,

    What kind of load on demand hacks do you mean? Can you give some examples?

    Anyways, we are working on a series of Code Library projects that will show RadComboBoxes in different setups: in FormView, RadGrid EditItemTemplate, with and without Load On Demand, related RCBs in FormView, RadGrid, etc. As we are ready with each one we will publish it in RCBs Code Library section on our site.

    We hope these examples will help you resolve issues with the setups more easily.

    Sincerely yours,
    Simon
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Sravan
    Sravan avatar
    7 posts
    Member since:
    Jul 2011

    Posted 13 Aug 2012 Link to this post

    The Link Is Not Working Can you please provide me a correct link.
  13. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010
  14. Golem
    Golem avatar
    21 posts
    Member since:
    Jun 2008

    Posted 27 Nov 2012 Link to this post

    Just a quick post to say that I found the JavaScript code posted by Simon back on April 15, 2010 to be very helpful.  I had the exact same scenario as the original poster, and the JavaScript code was exactly what I needed.  I made a slight modification to also check that the original text was not the empty string, since I did want the load-on-demand to occur in that scenario.

    Thanks!
Back to Top