How to set an initial value when using a web service

13 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 17 Feb 2009 Link to this post

    Hello,

    I need to set an initial value to a combo which uses LoadOnDemand with a web service as in your sample.
    As the combo items collection is initially empty, I am unable to select the value for my initial choice.

    I must says that apart from this little pb, load on demand works perfectly.

    CS
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 18 Feb 2009 Link to this post

    Hello Christian,

    I suggest you set EmptyMessage property of RadComboBox.

    Regards,
    Yana
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 18 Feb 2009 Link to this post

    Thanks Yana but it is not the feature I am exptecting, I need to initialize the combo with a value entered in this same combo on a previous session, I am in update mode.
    CS
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 19 Feb 2009 Link to this post

    Hi Christian,

    Then I suggest you subscribe to OnClientDropDownOpening event of RadComboBox and  invoke explicitly the RequestItem(itemText, bool) method:

    <script type="text/javascript">  
         function GetItems(sender, eventArgs)    
         {   
            sender.requestItems(sender.get_text(), false);    
         }    
    </script> 

    All the best,
    Yana
    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.
  6. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 19 Feb 2009 Link to this post

    Yana,
    Thanks but I need to display the actual value as soon as the combobox s displayed.
    Seems a normal concern, isn't it ?
    Would you expect your users to have to click on the combo to obtain existing data ?

    You are explaining that when LoadOndemand is used, RadCombobox is unable to display the actual selection ?
    If I'am right, this is a bug.

    CS
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 20 Feb 2009 Link to this post

    Hello Christian,

    Sorry for my previous reply, I misunderstood the scenario.

    When you use Load-On-Demand, RadComboBox doesn't load items initially, but you can set its Text in Page_Load event to have a selected value.

    Kind regards,
    Yana
    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.
  8. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 20 Feb 2009 Link to this post

    Thanks gain but,

    Problem is that as for normal combos, I don't store display text but associated value.
    Is there a way to says I need to display Text associated with this value ?

    CS
  9. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Feb 2009 Link to this post

    Hello Christian,

    I suggest you add the item with Text and Value in Page_Load:

    RadComboBoxItem item = new RadComboBoxItem("some text", "some value");  
    RadComboBox1.Items.Add(item); 
    but in this way the combobox will not request items the first time you open the dropdown, so you need to request them manually, you can do that with the code form my first post: subscribe to OnClientDropDownOpening and call requestItems in its handler:

    <script type="text/javascript">     
         function onDropDownOpening(sender, eventArgs)       
         {      
            sender.requestItems(sender.get_text(), false);       
         }       
    </script>    
     

    Best wishes,
    Yana
    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.
  10. Atlas
    Atlas avatar
    97 posts
    Member since:
    Jun 2009

    Posted 17 Jul 2009 Link to this post

    This is ridiculous. It appears that the Telerik LoadOnDemand controls only work in scenarios where you are inserting data. They will never work for an update scenario, as indicated in the previous entries of this post. Let's say, for example, you are using LoadOnDemand to update a company record. The Company Names are:
    Company 1
    Company 2
    Company 3
    Company 4
    ..etc.

    You set the initial value to Company 4, and the user decides to change the existing value to something that will cause the control to go grab more records. Once this happens, the new set of returned values will no longer include the initially selected value.

    In order for LoadOnDemand to have any value for updates, you would need to be able to persist the existing value of the data through multiple data retrievals, or manually add it everytime the control reloads, if it does not already exist.
  11. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Jul 2009 Link to this post

    Hi Nano,

    This depends on the logic in ItemsRequested event handler. Additionally  you can use ShowMoreResultsBox/EnableVirtualScrolling properties in order to load the items on portions.

    Regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  12. Steve
    Steve avatar
    11 posts
    Member since:
    Feb 2011

    Posted 05 Oct 2011 Link to this post

    Telerik,

    This is also a concern for our application. Hopefully you have a solution to this:

    We have an application that has something implemented called "Sticky Filters". Basically the idea is to persist data the user applies to a page (dropdown selections, specific text in a textbox, selected items in a checkbox list, specifically organized column headers in a grid, column widths in a grid). Again, these are all specific to how the user "sets up" their UI in our application.

    We need the ability to have ajaxified comboboxes (real ajax calls to a WCF using json) since some of the items in the lists can be thousands of records (im not going to justify this either way, its the requirement...). So, when a user selects an option in a dropdown "Item10001", we persist that. When the page loads, we need a way to set the selected text and value for this persisted item.

    Is there a way to do this? Another catch is, we need the ability to use this with dependant dropdowns. So the persisted value gets applied on page load to RadComboBox1 and fires the OnClientSelectedIndexChanged to load values in RadComboBox2.

    Can Telerik ComboBoxes handle this (with LoadOnDemand, webservices, etc) and can you please provide a demo or code? And can this be accomplished in clientside javascript?
  13. Atlas
    Atlas avatar
    97 posts
    Member since:
    Jun 2009

    Posted 05 Oct 2011 Link to this post

    In the update scenario, the control should default to the existing value.
    I ended up using a union select to return the existing result with what the user was typing in so that if the results were different, the existing value would still be returned.
  14. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 10 Oct 2011 Link to this post

    Hi Steve,

    Please refer to the following demo demonstrating the different Load On Demand scenarios. Also please refer to the following demo showing a scenario with related comboboxes.

    In your particular case you should set text and value to the first one of the related comboboxes on page load. In case you want load data in the second combobox based on the value set in the first one you should subscribe on the  OnClientLoad event and use the approach from the second demo in order to initiate a request for items.

    Regards,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017