This is a migrated thread and some comments may be shown as answers.

custom filter returns trash

1 Answer 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 29 Oct 2011, 05:53 PM
Hi,

We have a RadGridView that uses a custom filter row. When we filter by a value that returns no results the clear the filter or give it a value that should return results, what we get back is an unintelligible set of characters that overwrite each other on a single line. I've included 3 screen shots that capture the results in the grid before filtering, after filtering with a bogus value and after clearing the filter. The 3rd shot is the trash shot. Here is the method where we deal with a change in the filter.

private void FilterCell_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    var columnHeader = (ColumnFilterCell)sender;
 
    if (e.PropertyName != "IsFilterActive") return;
 
    if (columnHeader.IsFilterActive)
        this.radGridView.FilterDescriptors.Add(columnHeader.FilterDescriptor);
    else
        this.radGridView.FilterDescriptors.Remove(columnHeader.FilterDescriptor);
 
    var be = this.radGridView.GetBindingExpression(RadGridView.ItemsSourceProperty);
    var dataItem = be.DataItem;
    var path = be.ParentBinding.Path;
    if (dataItem == null || path == null) return;
 
    var prop = dataItem.GetType().GetProperty(path.Path);
    if (prop == null) return;
 
    var value = prop.GetValue(dataItem, null);
    if (value == null) return;
 
    if (value is PagedCollectionView)
    {
        var pagedCollectionView = value as PagedCollectionView;
 
        pagedCollectionView.Filter = FilterColumn;
        pagedCollectionView.Refresh();
    }
    else if (value is QueryableDomainServiceCollectionView<Model.Models.CustomJobSetWorkflowTask>)
    {
        var collection = value as QueryableDomainServiceCollectionView<Model.Models.CustomJobSetWorkflowTask>;
 
        if (collection.IsEmpty) collection.Load();
        collection.Refresh();
    }
}

The problem is in the last "else if". We've tried a number of things to get this to work. The if where we check to see if the collection is empty and reload doesn't work. How can we get the grid to display the values it displayed before we added the bogus filter?

Thanks,
Mike

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 02 Nov 2011, 04:43 PM
Hi Mike,

From the source code you have pasted, I have noticed that you are using the QueryableDomainServiceCollectionView class. In case you want to perform server-side filtering, you can add the FilterDescriptors directly to the QDSCV instead of RadGridView. If its AutoLoad is set to true it will go to the server each time the filtering criteria changes or when a FilterDescriptor is added/removed. If its AutoLoad is false, you can decide when to call its Load method manually in order to make it go to the server.

Now regarding the empty-ness of the QDSCV. If I understand you correctly, when the QDSCV goes to the server and brings back zero records of data its IsEmpty property still returns false? What do its ItemCount and TotalItemCount properties read? Does calling the Load method trigger a trip to server? You can attach to the LoadingData and LoadedData events of the QDSCV in order to debug what is going on and when. By the way, calling Load is enough, don't call Refresh since it is exactly the same.

Is it possible to send us a sample project that demonstrates the problem. I have attached a dummy sample project with a DB that you can use as a base to create your sample project. It contains two QDSCV's in a view model but you can delete one of the them. All the RIA stuff is already set up and runnable in this project.

We are looking to hearing from you.

Greetings,
Ross
the Telerik team

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

Tags
GridView
Asked by
Mike
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Share this question
or