Load On Demand + Show All?

11 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    92 posts
    Member since:
    Feb 2007

    Posted 29 Feb 2008 Link to this post

    Hi,

    I could do with some advice on how to implement some functionality.

    I have multiple RadComboBoxes with load on demand functionality so the user can type in the first few characters of the entry they want to find and the results will return accordingly.  I have the ShowMoreResults disabled as I want the combo to bring back all matching results regardless of the number.  This is all fine and works correctly.

    However, I would like to add to the combo some way of enabling the user to show all available results regardless of text entered.  I had initially thought of enabling the ShowMoreResultsBox and catching when this is clicked and manually setting the search text entered in the combo to an empty string to trigger a load of the full available list of items.  However, there does not seem to be any way to catch when this is clicked. 

    Can anyone suggest a way in which I can achieve this?

    Thanks in advance.
  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 29 Feb 2008 Link to this post

    Hello Jonathan,

    When this image is clicked a load on demand request  the text of RadComboBox is sent to the page. You can override this behavior as you paste the following javascript in your page:

    Telerik.Web.UI.RadComboBox.prototype._onMoreResultsBoxClickDelegate = function ()
    {

      alert(1);  //place your code here.
    }

    Hope this helps.

    Sincerely,
    Rosi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jonathan
    Jonathan avatar
    92 posts
    Member since:
    Feb 2007

    Posted 29 Feb 2008 Link to this post

    Hi Rosi,

    Thanks for that, that is indeed useful to know.  However, where would I actually put this code?  I placed this in my page with the comboboxes on it and it seems it is never entered.  How could I use this to set the text in the combobox to an empty string?

    Thanks in advance.
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 29 Feb 2008 Link to this post

    Hi Jonathan,

    Here is the full javascript code that you should place in your aspx page:

    <script type="type="text/javascript""
    Telerik.Web.UI.RadComboBox.prototype._onMoreResultsBoxClickDelegate = function () 
       //here RadComboBox1 is the ID of the combo 
       var combo = $find("<%= RadComboBox1.ClientID %>"); 
       combo.requestItems(""true); 
    </script> 

    Let me know how it goes.

    Kind regards,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Jonathan
    Jonathan avatar
    92 posts
    Member since:
    Feb 2007

    Posted 03 Mar 2008 Link to this post

    Hi,

    I'm afraid I cannot get this to work - the delegate function is never entered.  Besides, as I can have several comboboxes on my page, all of which are dynamically generated, this would not be a very elegant solution.  Is there any way I can determine whether the ShowMoreResults box was clicked in the server-side ItemsRequested event?

    Thanks.
  7. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 04 Mar 2008 Link to this post

    Hello Jonathan,

    There is no way you can make sure whether the ShowMoreResultBox has been clicked. However, you can use the OnClientItemsRequesting and OnClientItemsRequested events to determine whether the ShowMoreResultBox has been clicked. There, you can check the get_appendItems() property of RadComboBox. It is false when the arrow has not been clicked and true otherwise.

    For an example -
    <telerik:RadComboBox ID="RadComboBox1" runat="server" Height="140px" Width="215px" 
    ShowToggleImage="True" Skin="WebBlue" style="vertical-align:middle;" EnableLoadOnDemand=true ShowMoreResultsBox=true 
     
    OnClientItemsRequesting="Requesting" OnItemsRequested="RadComboBox1_ItemsRequested" > 
        <Items> 
            <telerik:RadComboBoxItem Text="" /> 
        </Items> 
    </telerik:RadComboBox> 
    javascript
    <script type="text/javascript">    
          
        function Requesting(sender,e)  
        {  
            alert(sender.get_appendItems());  
        }  
    </script> 

    I have also attached a simple project illustrating the previous solution that we suggested. Note that this will override the behavior for all comboboxes on the page no matter if they were dynamically created or not.

    Kind regards,
    Rosi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Jonathan
    Jonathan avatar
    92 posts
    Member since:
    Feb 2007

    Posted 04 Mar 2008 Link to this post

    Thanks for your help Rosi, thats exactly what I needed :-)
  9. Jonathan
    Jonathan avatar
    92 posts
    Member since:
    Feb 2007

    Posted 05 Mar 2008 Link to this post

    Hi,

    What looks like a great solution is actually a bit problematic.  I have the following issues:

    Using the client-side delegate to catch the ShowMoreResultsBox click now works, but how can I get access to the combo which raised the event in order to modify the text of it?  There are no arguments to the delegate function.

    Another issue is that adding a client-side OnClientItemsRequesting event, the JavaScript method (shown below) is correctly entered when the ShowMoreResultsBox is clicked - the problem is that on the first time through, get_appendItems() returns false.  On the second click it returns true.

    function Requesting(sender,e)  
    {  
        alert(sender.get_appendItems());  
    }

    A solution to either of these issues would result in it behaving exactly as I require.  Can you help?
  10. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 07 Mar 2008 Link to this post

    Hi Jonathan,

    the event handler of the OnClientItemsRequesting takes two parameters - sender and eventArgs.
    sender parameter is the instance of the combobox firing the event.
    So you can use
    sender.set_text("my text here");
    for example.

    For your second question - I suggest that you hook on the OnClientItemsRequested event instead of OnClientItemsRequesting.
    In this case you do not need to modify the Requesting javascript function, because the parameters it takes are the same.

    I hope this helps.

    Greetings,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 09 Jun 2010 Link to this post

    I'm looking for the same functionality and am having trouble wiring things up.

    How does the server know that the "ShowAll" was clicked?

    Here is my code thus far:
        <telerik:RadComboBox ID="RadComboBox1" runat="server"   
            ShowToggleImage="True" EnableLoadOnDemand="true" 
            ShowMoreResultsBox="true"  OnClientItemsRequested="Requested"   
            OnItemsRequested="RadComboBox1_ItemsRequested"   
            EnableVirtualScrolling="True" ItemsPerRequest="10">  
                <Items> 
                    <telerik:RadComboBoxItem Text="" /> 
                </Items> 
        </telerik:RadComboBox> 
     
        <script type="text/javascript">  
     
            function Requested(sender, e)   
            {  
                alert(sender.get_appendItems());  
            }  
        </script>   


     protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)  
        {  
            RadComboBox RadComboBox1 = (RadComboBox)sender;  
     
            RadComboBox1.Items.Clear();  
     
            RadComboBox1.DataSource = GetData();  
        }  
     
        private List<string> GetData()  
        {  
            List<string> items = new List<string>();  
     
            for (int i = 0; i < 100; i++)  
            {  
                items.Add("Item " + i);  
            }  
     
            return items;  
        } 


  12. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 09 Jun 2010 Link to this post

    do you know because the RadComboBoxItemsRequestedEventArgs Text property is empty?

    Also, is there a way to isolate this functionality to just one combobox on the page?

    Thanks in advance,
    Gene.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017