Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to implement accent-insensitive filtering in ASPxGridView bound to Server Mode data source

$
0
0

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:

[C#]
stringICustomFunctionOperatorFormattable.Format(TypeproviderType,paramsString[]operands){varoperand=string.Format("N'%{0}%'",operands[0].Split('\'')[1]);returnstring.Format("{0} COLLATE SQL_Latin1_General_CP1_CI_AI LIKE {1} ",operands[1],operand);}
[VB.NET]
PrivateFunction ICustomFunctionOperatorFormattable_Format(ByVal providerType As Type, ParamArrayByVal operands() AsString) AsStringImplements ICustomFunctionOperatorFormattable.FormatDim operand = String.Format("N'%{0}%'", operands(0).Split("'"c)(1))ReturnString.Format("{0} COLLATE SQL_Latin1_General_CP1_CI_AI LIKE {1} ", operands(1), operand)EndFunction

 

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


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>