IColumnFilterDescriptor & DistinctFilter Slowness

3 posts, 0 answers
  1. Richard
    Richard avatar
    122 posts
    Member since:
    Feb 2009

    Posted 20 Feb 2013 Link to this post


    I have been running into a problem with programmatically filtering a grid. I have been using the IColumnFilterDescriptor  & DistinctFilter, it works but they are very slow when the number of items to filter is high. 

    I have a grid of around 20K rows, and I'm adding about 200 items to the Distinct filter. This can take minutes to filter during which the UI is blocked and sometimes crashes completely. 

    What's the best way to filter a large grid by a large number of distinct items ?

    Also from my code snippet below, you can see what I'm actually trying to do is filter my grid by the currently selected rows, is there a better way of doing this without using the DistinctFilter ?


    IColumnFilterDescriptor columnFilter = matchingColumn.ColumnFilterDescriptor;
    List<int> filterItems = (from DeploymentItem row in GridDeploymentList.SelectedItems select row.DeploymentId).ToList();
    foreach (int deplymentId in filterItems) columnFilter.DistinctFilter.AddDistinctValue(deplymentId);
  2. Rossen Hristov
    Rossen Hristov avatar
    2477 posts

    Posted 21 Feb 2013 Link to this post


    We use LINQ for filtering. Adding 200 distinct values will produce the following LINQ clause:

    var result = sourceCollection.Where(item => item.DeploymentId == 1 || item.DeploymentId == 2 ... item.DeploymentId == 200);

    So you can imagine that this LINQ query will not be very fast. Unfortunately, we cannot do anything in order to speed up the Silverlight client. In Silverlight, a Where clause can only be certain length after which the runtime will eventually crash. These are limitations of the runtime which we have no control over.

    Building a simpler filter such as DeploymentId > 5 && DeploymentId < 100 will be fatser.

    I am afraid that we cannot offer any workaround for the task that you want to achieve.

    All the best,
    Rossen Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Richard
    Richard avatar
    122 posts
    Member since:
    Feb 2009

    Posted 21 Feb 2013 Link to this post

    Thanks Rossen , that's a shame, I thought it might be something like that but I can't complain the control set set is excellent

Back to Top