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

Load On Demand + Show All?

10 Answers 178 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 29 Feb 2008, 09:35 AM
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.

10 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 29 Feb 2008, 03:22 PM
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
0
Jonathan
Top achievements
Rank 1
answered on 29 Feb 2008, 03:40 PM
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.
0
Veselin Vasilev
Telerik team
answered on 29 Feb 2008, 03:47 PM
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
0
Jonathan
Top achievements
Rank 1
answered on 03 Mar 2008, 02:57 PM
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.
0
Rosi
Telerik team
answered on 04 Mar 2008, 12:00 PM
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
0
Jonathan
Top achievements
Rank 1
answered on 04 Mar 2008, 01:44 PM
Thanks for your help Rosi, thats exactly what I needed :-)
0
Jonathan
Top achievements
Rank 1
answered on 05 Mar 2008, 11:36 AM
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?
0
Veselin Vasilev
Telerik team
answered on 07 Mar 2008, 08:10 AM
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
0
Gene
Top achievements
Rank 1
answered on 09 Jun 2010, 10:41 PM
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;  
    } 


0
Gene
Top achievements
Rank 1
answered on 09 Jun 2010, 11:25 PM
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.
Tags
ComboBox
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Jonathan
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Gene
Top achievements
Rank 1
Share this question
or