Hi,
I want to apply the filter to radgridview programatically. This is the piece of code I am using :
FilterExpression filter =
null
;
object
currentCellValue =
null
;
if
(grdSearch.CurrentCell !=
null
) currentCellValue = grdSearch.CurrentCell.Value;
if
(grdSearch.Columns[grdSearch.CurrentColumn.HeaderText].Filter !=
null
)
{
filter = grdSearch.Columns[grdSearch.CurrentColumn.HeaderText].Filter;
}
else
{
filter =
new
FilterExpression(grdSearch.CurrentColumn.HeaderText);
}
if
(grdSearch.CurrentCell.Value !=
null
)
{
filter.Predicates.Add(FilterExpression.BinaryOperation.AND,
GridKnownFunction.NotEqualTo,
string
.Format(
"@FilterEditor{0}"
,filter.Predicates.Count + 1));
filter.Parameters.Add(
string
.Format(
"@FilterEditor{0}"
,filter.Predicates.Count), currentCellValue);
}
else
{
filter.Predicates.Add(FilterExpression.BinaryOperation.AND, GridKnownFunction.NotIsNull,
null
);
}
this
.grdSearch.Columns[grdSearch.CurrentColumn.HeaderText].Filter = filter;
This code is executed when user clicks the contextmenu opened after right clicking one of the gridcell.
This piece of code works properly if the cell value has no special character. For example, it works if cell value is 'Microsoft Word' but
if the cell value is 'MS Visio 3/4 Document/Drawing/Shapes/Te', it is being stored as 'MS Visio 3[/]4 Document[/]Drawing[/]Shapes[/]Te' by the Filter object and thus Filter is applied but is not working.
Please check the attached image file to see how Filter is storing the parameters with special characters.
regards,
Bibek Dawadi