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

Applying Filter to GridView

2 Answers 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Namir Ahmed
Top achievements
Rank 1
Namir Ahmed asked on 23 Oct 2009, 08:48 PM
Hi,

I am applying a filter programmatically to a Telerik GridView so that only those records which match the selection
should be shown. My predicate seems to be filtering the results correctly but my source collection is never filtered. Here is my
sample code:

//Setting Data Context here

 

internal void BuildReportObjectCollection()

 

{

 

List<ReportObjectEntity> reportObjectCollection =

 

Presenter.buildReportObjectCollection();

SingleObjectList.DataContext = reportObjectCollection;

}


//Use the list of Guids to filter my collection using
//the predicate here

 

 

public void Show(List<Guid> reportObjectList)

 

{

selectdReportObjectCollection = reportObjectList;

 

if (selectdReportObjectCollection != null)

 

{

 

if (SingleObjectList.ItemsSource != null)

 

    {

 

     // filter

 

 

 

 

    collectionView =

CollectionViewSource.GetDefaultView(SingleObjectList.DataContext);

 

    collectionView.Filter =

new Predicate<object>(FilterForSelectedReportObjectList);

 

    }

}

}


 

public

 

bool FilterForSelectedReportObjectList(object item)

 

{

 

ReportObjectEntity reportObject = item as ReportObjectEntity;

 

 

if (reportObject != null && this.selectdReportObjectCollection.Contains(reportObject.ReportObjectID))

 

{

 

return true;

 

}

 

else

 

 

 

 

{

 

return false;

 

}

}

//The XAML is pretty standard for the GridView,  ItemsSource = {Binding}

Does anyone know what is the issue here?


Thanks,

2 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 26 Oct 2009, 07:41 AM
Hi Namir,

We have recently fixed an issue with filtered CollectionView. Can you try to upgrade to the latest internal build  that targets Q3 (2009_3_1023) and verify that the issue is fixed?

All the best,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Namir Ahmed
Top achievements
Rank 1
answered on 26 Oct 2009, 08:40 PM
Hi,

Thanks for your reply. I used a custom FilterDescription object and that works well for me.

--
Namir
Tags
GridView
Asked by
Namir Ahmed
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Namir Ahmed
Top achievements
Rank 1
Share this question
or