Is it possible to change RadComboBox Filter on the client side?

6 posts, 0 answers
  1. Water
    Water avatar
    13 posts
    Member since:
    Jan 2012

    Posted 02 Dec 2013 Link to this post

    I want the user to be able to change the Filter option between StartsWith and Contains by using a couple of radio buttons. Is it possible to do this client side or do I have to do a postback to change this setting?
  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 03 Dec 2013 Link to this post

    Hello Water,

    You could use the set_filter() client-side function, in order to apply a desirable filter. The function accepts tree values as arguments :

    • 0 : filter - None
    • 1 : filter - Contains
    • 2 : filter - StartsWith

    Regards,
    Nencho
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Water
    Water avatar
    13 posts
    Member since:
    Jan 2012

    Posted 03 Dec 2013 Link to this post

    Thanks for that. I created a function using the set_filter method however this only seems to effect what text is highlighted in the search results, rather than what search results are returned, am I missing something?

    function SetComboBoxSearchFilter(comboBoxClientId, filterNumber)
    {
        var comboBox = $find(comboBoxClientId);
        comboBox.set_filter(filterNumber);
     
        if (comboBox.get_text() != '' && comboBox.get_text() != comboBox.get_emptyMessage())
        {
            comboBox.clearItems();
            comboBox.requestItems(comboBox.get_text(), false);
        }
    }
  5. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 06 Dec 2013 Link to this post

    Hello Water,

    I tried the approach that you are currently using and it seems to work properly. Here is a video, demonstrating the behavior at my end, when the StartsWith(2) is used. I noticed that you are using requestItems function. Had you enabled the LoadOnDemand functionality? In this case, I would suggest you to implement the filter at server-side, like demonstrated in our online demo here. Passing the currently typed text in the input of the ComboBox, you could then easily filter the query returned for your datasource, like demonstrated in the SourceCode of the referenced demo (Product ComboBox).

    Regards,
    Nencho
    Telerik
    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 the blog feed now.
  6. Water
    Water avatar
    13 posts
    Member since:
    Jan 2012

    Posted 09 Dec 2013 Link to this post

    Yes, I am using Load On Demand. Would this prevent the client side method from working correctly? In any case, I have the server side method working, I was just trying to reduce the number of postbacks.
  7. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 12 Dec 2013 Link to this post

    Hello Water,

    Would you provide us with your entire implementation of the RadComboBox and specify how do you attempt to reduce the number of postbacks? By default the ItemsRequested event is fired each time a character is typed in the input of the control. Do you cancel the propagation of the event, in order to implement custom logic?

    Regards,
    Nencho
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017