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

Is there something like a DisplayMemberPath or FilterMember

2 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dominik
Top achievements
Rank 1
Dominik asked on 08 Sep 2011, 11:17 AM
Hi

We have a Silverlight 4 application and use it in combination with RIA services. All the filterning/sorting/grouping/paging is therefore done serverside. We have now encountered a problem:

In order for a column to be filterable (sortable etc), there has to be a corresponding field in the database. For this reason, we have some calculated fields that show the number of linked entities (integer field that returns the count()).  What causing us trouble is the following:
in a use case, we can assign entities but the user does not yet save the items to the database. The "Count" field in the grid has to reflect the temporary changes. However, when we update the count of the calculated field (generated by the ria services, it has a setter!!) the tracked entity is marked as modified which prevents the user from furhter filtering, paging in the concerned grid (i believe it is because the domain datasource.HasChanges is true).

To solve the issue, i have set the GridViewBoundColumnBase.SortMemberPath and the GridViewBoundColumnBase.GroupMemberPath to the acutal field in the database and the GridViewBoundColumnBase.DataMemberPath to the temporary field. This works well, except for the filtering. Filtering does not work because, the column the application tries to filter on, does not exist in the database!

In short: what I need is the following:
Analogous to SortMemberPath or GroupMemberPath in the GridViewBoundColumnBase I would need a FilterMemberPath property (or alternativly a DisplayMemberPath! 
As this does not exist, is there a workaround?

Greetings and thanks in advance..

2 Answers, 1 is accepted

Sort by
0
Dominik
Top achievements
Rank 1
answered on 08 Sep 2011, 11:31 AM
I just found a solution:

Maybe not the best but it seems to work. Any better proposals are appreciated
 
public class CustomDataColum : GridViewDataColumn
    {
 
 protected override object GetCellContent(object item)
        {
            if(DisplayMemberPath!=null && item!=null)
            {
                var propInfo = item.GetType().GetProperty(DisplayMemberPath);
                var toReturn =propInfo.GetValue(item, null);
                return toReturn;
            }
            return base.GetCellContent(item);
        }
0
Rossen Hristov
Telerik team
answered on 08 Sep 2011, 02:05 PM
Hello Dominik,

We don't have a FilterMemberPath for various complex reasons concerning our data engine and RadGridView's filtering infrastructure. 

But, we have offered another feature called Custom Filtering Controls that allows the developer to create any kind of filtering logic inside a custom filtering control. I also have a blog post that shows how to perform filtering directly on the server with the help of a custom filtering control. Your custom control can use our generic FilterDescriptor<T> which allows custom filtering Expressions.

I hope this helps.

Greetings,
Ross
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

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