Combo box filters

3 posts, 1 answers
  1. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 20 Jul 2009 Link to this post


    I'd like to have a filter that uses a combo box instead of the normal text box.  I've seen two different examples of this on the site as the Google style filtering and then another one using Countries as the datasource for it.

    Both methods are horrible in the amount of effort that they will require to implement and then maintain.  I have seen that the DevExpress grid has the feature and it is pretty much a case of setting a flag on the grid to show the drop down.

    Have I missed something in the demos etc and is there an easy way to do this?  I'm not afraid of hard work but would have thought that a simple way to do this would have been part of the RAD approach.


  2. Answer
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 20 Jul 2009 Link to this post

    Hi Jon,

    AFAIK a little bit of code is neede to implement CB Sorting.
    I always use the approach with the codeblock in the filtertemplate.
        <telerik:RadComboBox Width="160px" ID="rcbKulturkreisFilter" DataSourceID="odsKulturkreise" DataTextField="Name" DataValueField="ID" Height="200px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("KulturkreisID").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="KKFilterIndexChanged" DropDownWidth="240px">  
                <telerik:RadComboBoxItem Text="Alle" /> 
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">  
            <script type="text/javascript">  
                function KKFilterIndexChanged(sender, args) {  
                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");  
                    tableView.filter("KulturkreisID", args.get_item().get_value(), "EqualTo");  

    And yes I also had to work with a control which offers "autocombofiltering".
    My problem there was in some situations I got hundreds of entries in this combobox.
    And it was almost impossible to remove them.

    With the telerik this solution I have to write a bit of code BUT
    a.) I didn't develope this code - I found it in the forum (so 5 minutes search - copy and paste)
    b.) It's always the same pattern - copy and paste again :)
    c.) it's totally customizable

    For c.) and my "hundreds of entries" I built a simple function (server side) which extracts the first x letters from the possible values.
    That was my datasource for the filter listbox. And as operator I used StartsWith - done.

    I also have a filter with contains as criteria - so I can filter for an example for "eggs" and find "easter eggs, rotten eggs, colored eggs with...).

    I don't know if the controls you're talking about has the ability to do things like this - RadGrid does.
    The price for it - 5 lines of (copy and paste) code.
    And if you really need it often - it should be possible to build a user control for this job.
    Which should result in adding a filtertemplate with exactly that control and passing an ID to it.

    Last not least - yes there are situations where I also would like to have an "autocombofilterflag" :)


  3. DevCraft R3 2016 release webinar banner
  4. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 20 Jul 2009 Link to this post

    Hi Manfred,

    Thanks for the help on that - this is a much simpler way of doing it than the other examples that I saw.

    I think that the DevExpress grid does everything for you on the filtering front and will only show entries that are relevant - you don't need to hook up extra datasources and all that.  I'd be great if the guys at Telerik could implent something of that sort into the grid. 

    I think I'll try the custom control route as I'll need quite a few of these as well as some date range filters.  Should be fun ;)

    Thanks for the help,


Back to Top