I am trying to filter on a value in a child array of an object using server side filtering
I have an object like:
On a grid I generate a custom filter template which allows a user to filter by Accounts (e.g a dropdown list of accounts).
The datasourcerequest object on the server is populated with a filter. I want to be able to intercept the filter and change the filter from an equals
to a contains
I've done the following
private DataSourceRequest InterceptRequest(DataSourceRequest request)
{
for (int idx = 0; idx < request.Filters; idx++)
{
var flt = filterList[idx] as FilterDescriptor;
if (flt != null && flt.Member.ToString().Equals("accountIdList"))
{
flt.Operator = FilterOperator.Contains;
flt.Value = 1; //Hardcode as an example
}
}
}
However when I call ToDataSourceResult I get an error stating an invalid cast from Int32 to IEnumerable<Int32>
I want to get a list of all persons who have an Account Id of 1. How can I achieve this?
I have an object like:
public
class
person{
public
int
id {
get
;
set
;}
public
List<
int
> accountIdList {
get
;
set
;} <br>
}
On a grid I generate a custom filter template which allows a user to filter by Accounts (e.g a dropdown list of accounts).
The datasourcerequest object on the server is populated with a filter. I want to be able to intercept the filter and change the filter from an equals
to a contains
I've done the following
private DataSourceRequest InterceptRequest(DataSourceRequest request)
{
for (int idx = 0; idx < request.Filters; idx++)
{
var flt = filterList[idx] as FilterDescriptor;
if (flt != null && flt.Member.ToString().Equals("accountIdList"))
{
flt.Operator = FilterOperator.Contains;
flt.Value = 1; //Hardcode as an example
}
}
}
However when I call ToDataSourceResult I get an error stating an invalid cast from Int32 to IEnumerable<Int32>
I want to get a list of all persons who have an Account Id of 1. How can I achieve this?