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

How to set an initial value when using a web service

12 Answers 241 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
CSurieux
Top achievements
Rank 2
CSurieux asked on 17 Feb 2009, 06:39 PM
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

12 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 18 Feb 2009, 12:34 PM
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.
0
CSurieux
Top achievements
Rank 2
answered on 18 Feb 2009, 12:45 PM
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
0
Yana
Telerik team
answered on 19 Feb 2009, 12:08 PM
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.
0
CSurieux
Top achievements
Rank 2
answered on 19 Feb 2009, 12:55 PM
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
0
Yana
Telerik team
answered on 20 Feb 2009, 10:54 AM
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.
0
CSurieux
Top achievements
Rank 2
answered on 20 Feb 2009, 02:24 PM
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
0
Yana
Telerik team
answered on 23 Feb 2009, 01:08 PM
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.
0
Atlas
Top achievements
Rank 1
answered on 17 Jul 2009, 06:30 PM
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.
0
Yana
Telerik team
answered on 21 Jul 2009, 11:21 AM
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.
0
Steve
Top achievements
Rank 1
answered on 05 Oct 2011, 07:22 PM
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?
0
Atlas
Top achievements
Rank 1
answered on 06 Oct 2011, 12:55 AM
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.
0
Dimitar Terziev
Telerik team
answered on 10 Oct 2011, 11:55 AM
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
Tags
ComboBox
Asked by
CSurieux
Top achievements
Rank 2
Answers by
Yana
Telerik team
CSurieux
Top achievements
Rank 2
Atlas
Top achievements
Rank 1
Steve
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or