I have a grid where the filters are done in the server, directly in database. One of my columns is a string representation of a number, like this:
public
string
NumberDisplay
{
get
{
if
(Number ==
null
)
return
"--"
;
else
return
Number.Value.ToString(
"0.##"
);
}
}
As this is a string, the grid will show the string filters (contains, starts with, etc). How can I force a numeric filter (greater than, less than, etc.) on a string column? This is how the filtering is done in the database (as a number, not as a string):
case
"NumberDisplay"
:
{
bool
addQueryParam =
true
;
string
sql =
null
;
switch
(filter.Operator)
{
case
GridFilterOperator.IsGreaterThan:
sql =
" and (@KendoNumber is not null and mm.Number is not null and mm.Number > @KendoNumber)"
;
break
;
...
}
if
(addQueryParam)
{
queryBuilder.Where(sql);
queryBuilder.AddParameter(
"KendoNumber"
, filterValue);
}
}
...