IColumnFilterDescriptor & DistinctFilter Slowness

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

    Posted 20 Feb 2013 Link to this post

    Hi,

    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 ?

    Thanks,
    Richard

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

    Posted 21 Feb 2013 Link to this post

    Hi,

    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. DevCraft banner
  4. Richard
    Richard avatar
    72 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

    Cheers,
    Ricard
Back to Top