Define custom filter predicate in listview

2 posts, 0 answers
  1. kim
    kim avatar
    3 posts
    Member since:
    Mar 2009

    Posted 02 Aug 2011 Link to this post

    Is it possible to do custom filtering in the listview like it is possible in radgridview?

    I want to do a contains filter on an integer column.  But this is not possible. In radgridview this was possible by setting the MasterTemplate.FilterPredicate.
  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 04 Aug 2011 Link to this post

    Hi Kim,

    You can achieve this functionality using the DataView property of the root ListViewElement. Here is a simple example:

    public partial class ListViewForm1 : Form
        public ListViewForm1()
            radListView1.EnableFiltering = true;
        private void ListViewForm1_Load(object sender, EventArgs e)
            // TODO: This line of code loads data into the 'northwindDataSet.Customers' table. You can move, or remove it, as needed.
            this.radListView1.ListViewElement.DataView.Filter = MyFilter;
        private bool MyFilter(ListViewDataItem item)
            if (item.Value.ToString().Contains('C'))
                return true;
            return false;

    For Q2 2011 SP1 release the RadLisView control will has its own FilterPredicate property the make the API easier to use.

    All the best,
    Julian Benkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. DevCraft banner
Back to Top