Files to look at:
- AccentInsensitiveFilterOperator.cs (VB: AccentInsensitiveFilterOperator.vb)
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx)
When ASPxGridView is bound to a server mode data source, all data operations are performed on the database server: Binding to Large Data (Database Server Mode)?. Thus, results depend on database settings. For instance, filtering data with diacritic signs depends on the default collation of your data server:
[CodeProject.com] Configuring SQL Server Accent-Insensitivity
[Stackoverflow.com] Questions about accent insensitivity in SQL Server (Latin1_General_CI_AS)?
In other words, the first solution to achieve accent-insensitive filtering when the grid is bound to the server mode datasource is to change collation on the server.
Another solution is to create a custom filter operator by implementing ICustomFunctionOperator and ICustomFunctionOperatorFormattable interfaces and modify a filtering request to the database in the ICustomFunctionOperatorFormattable.Format method:
string ICustomFunctionOperatorFormattable.Format(Type providerType, params String[] operands) {
var operand = string.Format("N'%{0}%'", operands[0].Split('\'')[1]);
return string.Format("{0} COLLATE SQL_Latin1_General_CP1_CI_AI LIKE {1} ", operands[1], operand);
}
Private Function ICustomFunctionOperatorFormattable_Format(ByVal providerType As Type, ParamArray ByVal operands() As String) As String Implements ICustomFunctionOperatorFormattable.Format
Dim operand = String.Format("N'%{0}%'", operands(0).Split("'"c)(1))
Return String.Format("{0} COLLATE SQL_Latin1_General_CP1_CI_AI LIKE {1} ", operands(1), operand)
End Function
In this case, the accent-insensitive collation is applied only for filtering. Note that this approach is not supported by LINQ-based ORMs.
This example demonstrates how to implement accent-insensitive filtering in Auto Filter Row when ASPxGridView is bound to XpoDataSource with Server Mode enabled. To test the example, download the solution to your local machine.
See Also:
How to make the Grid's filter to be a case- and accent-insensitive in Server Mode
E4836: How to create a custom ASPxGridView's filter insensitive to the number of spaces and punctuation
- Run the "DatabaseUpdater" project;
2) Generate sample data;
3) Run XpoWebApplication project.