Populate RadComboBoxItemsRequestedEventArgs Text property

6 posts, 0 answers
  1. Eugen
    Eugen avatar
    4 posts
    Member since:
    Jan 2015

    Posted 25 Jun 2015 Link to this post

    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 ?

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 30 Jun 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eugen
    Eugen avatar
    4 posts
    Member since:
    Jan 2015

    Posted 15 Jul 2015 in reply to Ivan Danchev Link to this post

    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?

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 20 Jul 2015 Link to this post

    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
  6. Eugen
    Eugen avatar
    4 posts
    Member since:
    Jan 2015

    Posted 31 Jul 2015 in reply to Ivan Danchev Link to this post

    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

  7. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 04 Aug 2015 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017