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

Populate RadComboBoxItemsRequestedEventArgs Text property

5 Answers 153 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Eugen
Top achievements
Rank 1
Eugen asked on 25 Jun 2015, 12:44 PM

Hi,

I have a RadCombobox on an aspx page that I'm trying to populate with one item at OnLoad using 

RadComboBoxItem newItem = getItem(id);
RadCombo1.Items.Add(newItem);
RadCombo1.SelectedValue = Request.QueryString["cid"];
RadCombo1.Text = newItem.Text;

After page finishes loading, while invoking RadCombo1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e), e has empty Text and loads data as if the box was empty.

Control on page:

<telerik:RadComboBox ID="RadCombo1" runat="server" 
                                        Width="300" MaxHeight="350" AllowCustomText="true" 
                                        MarkFirstMatch="true" 
                                        OnClientSelectedIndexChanged="OnClientSelectedIndexChanged"
                                        OnSelectedIndexChanged="RadCombo1_SelectedIndexChanged"
                                        EnableLoadOnDemand="true" EnableVirtualScrolling="true"
                                        OnItemsRequested="RadCombo1_ItemsRequested"
                                        ShowMoreResultsBox="true" Filter="Contains">
                                    </telerik:RadComboBox>

 

How can I set e.Text to my selectedItem.Text or invoke manually RadCombo1_ItemsRequested ?

5 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 30 Jun 2015, 10:35 AM
Hello,

In a Load on Demand scenario a better approach of adding new ComboBox items would be to use the ItemsRequested event handler and add the items in it, as demonstrated in the sample project attached to this reply.

e.Text in the context of the ItemsRequested event holds the text in the RadComboBox' input field but in order for that event to fire the user must type text into the input field or click on the drop-down toggle image when the list is empty. A third way to trigger the event is by calling the RadComboBox requestItems() client-side method. You can find more information about this method in the RadComboBox Object documentation article.

Regards,
Ivan Danchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Eugen
Top achievements
Rank 1
answered on 15 Jul 2015, 01:58 PM

Hi,

Thanks for response. RequestItems did the job with one issue: after using it, load on demand will get me only the first page of items ( scrolling down the list will not continue to fire ItemsRequested on server side). Any ideas why?

0
Ivan Danchev
Telerik team
answered on 20 Jul 2015, 09:02 AM
Hello,

Is the configuration of the ComboBox any different from the one in your first post and which event handler do you call the requestItems() method in?

Regards,
Ivan Danchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Eugen
Top achievements
Rank 1
answered on 31 Jul 2015, 11:19 AM

Configuration is the same.

Initially I tried to use requestItems on js pageLoad().

I also tried to do that on a checkbox client event but that failed as this call is asynch and I needed the item right away.

Just to clear thing out:

I have RadComboBox with LoadOnDemand. On c# Page_Load I want to populate the Combo with one item based on QueryString and then Combo should work normally, no duplicates in the list of items, no blocking of items loading process.

Thank you

0
Ivan Danchev
Telerik team
answered on 04 Aug 2015, 05:41 PM
Hello,

Did you try adding the item as suggested in the ItemsRequested handler and not in Page_Load? At my side this works correctly and if the ComboBox ItemsPerRequest property is not set the item will be added at the end of the Items collection without any repetition. Setting the ItemsPerRequest will create repetition as the item will be added after each set of requested items.

Regards,
Ivan Danchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
Eugen
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Eugen
Top achievements
Rank 1
Share this question
or