This is a migrated thread and some comments may be shown as answers.

Save/Load RadGrid Settings : FilterExpression Problem when changing CurrentThread Culture

1 Answer 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luca
Top achievements
Rank 1
Luca asked on 15 Dec 2015, 10:37 AM

Hello everyone.

In a multiuser, muticulture project, I have the necessity to save the grid settings.

 I have the following use case:

- One User , with CurrentThread.CurrentCulture == "de-DE", wants to  save the grid setting for a table with a column of type "GridDateTimeColumn".

- User filters for DateTime element. The FilterExpressionValue is something like that :
((CreatedDate >= DateTime.Parse(\"03.12.2015,00:00:00\")) AND (CreatedDate <= DateTime.Parse(\"19.12.2015,23:59:59\")))"

- User saves the grid settings

- User changes his culture to "en-US"

- User loads grid settings

The loaded FilterExpression doesn't work properly because RadGrid expects a DateTime in "en-US" format (MM/dd/yyyy) but get one in "de-DE" (dd.MM.yyyy).

There is the same problem with GridNumericColumn columns.

To solve it I performed the following solution.

I don't save/load directly the FilterExpression string, but on "Save" event i just save the CurrentFilterValue/CurrentFilterFunction for the single columns parsing  GridDateTimeColumn and GridNumericColumn in "InvariantCulture" format.

On "Load" event I load the CurrentFilterValue/CurrentFilterFunction parsing it in culture dependent format, and I generate the FilterExpression joining the FilterExpressions (EvaluateFilterExpression() method) of the single columns.

I wanted to know if it is the best approchor  or there are better solutions.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 18 Dec 2015, 08:11 AM
Hello Luca,

I understand the scenario and what is causing the problem, but since the FilterExpression is stored as a string, changing the culture between the saving and the loading of the settings will throw an exception. The workaround that you have found is the only valid one with the current implementation.

Nevertheless, you could log an item in our public portal, so that our developers team could investigate the possibility of providing a built-in approach for handling such scenario:

Best Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Luca
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or