Hi there,
in my case, I have a ViewModel on the client side. It works and shows the data from the "real" model. The real model consists of an object that contains other objects, e.g.
ArchivedDoubleValue refers to a
Station, which has a name, via its StationId. In my ViewModel, things are flattened in order to be fast and avoid circular dependencies, so there is:
int Id (ArchivedDoubleValue.Id)
double Value (ArchivedDoubleValue.Value)
string StationName (refers to Station.Name and gets set in the controller)
Now, when I want to sort or filter the StationName column, I run into an error, because StationName does not exist in the "real" model, only StationId.
So I thought I could simply "translate" the
Member String in
DataSourceRequest.Groups and
DataSourceRequest.Sorts back into the corresponding Id. That worked quite well:
When grouping in the client, the
request.Groups contains an entry with its
Member set to "
StationName". This is just a string and I change it to the corresponding StationId. Same works well for sorting.
But it DOES NOT work for filtering! When debugging and peeking into he request at runtime, I can see and change the
Filters Members and Values, but when I try to change it via code in the controller, I can not access it:
if (request.Filters.Count > 0)
{
foreach (var f in request.Filters)
{
String fs = f.Member.ToString();
This gives me an error:
Kendo.Mvc.IFilterDescriptor does not contain a definition for "Member"
How am I supposed to filter the "real" data with the filter set to a column in my ViewModel? I wonder how to do that? Or is there a way to access request.Filters? I think that would be the most elegant way to do it as it wiould be transparent to the client.
Please help me with that, thanks in advance!
Regards, Rob