alirezanet/Gridify

Possibility to have the filter value of a different type of field type

mdiflo-kampaay opened this issue · 1 comments

Details

We tried to create a new custom filter operator to manage the In filter with a custom operator #in and use it with the string filter id#in1;2, with the purpose of using LINQ and doing something like filter.Value.Split(';').Contains(Id).

public class InOperator : IGridifyOperator
{
    public string GetOperator() => "#in";

    public Expression<OperatorParameter> OperatorHandler() =>
        (prop, value) => ((string)value).Split(';', StringSplitOptions.None).Contains(prop.ToString());
}

The field Id is an int and the value is a string that we'll have to split to retrieve an array.

In this case, we receive an error that says the String value cannot be converted into Int type because inside GenerateExpression, the library tries to convert the value of the filter in the same type of field if the type of the field can be converted from a string (in this case yes because an int can be converted into a string)

image

Is there a way to implement a filter like the In and we're doing something wrong or not?

Hi @diphlo,
Thank you for the feedback, it is fixed in v2.9.2 .