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

Report Viewer Filter Section Date Format

16 Answers 782 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
louis chan
Top achievements
Rank 1
Iron
louis chan asked on 12 Oct 2012, 01:44 AM
I create a web report using win2003 using locale OS date format yyyy/mm/dd HH:mm:ss and the display format on the filter parameters section is yyyy/mm/dd with debug locally on the development machine as shown 1.jpg. However, I publish the web to Win2008R2 SP2 using the same locale OS date format yyyy/mm/dd HH:mm:ss and the display format on the filter parameters section is mm/dd/yyyy as shown on the attached 2.jpg. Please advise what I should do on the win2008R2 SP2 machine to display the same as 1.jpg. What is affecting the date time display format. The development and production machines are having the same date time format setting.

Thanks in advance.

16 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 16 Oct 2012, 09:08 AM
Hello Louis,

If you have set Culture only to the Report, please set the Culture of the CurrentThread and it should be displayed as you want.
The Culture of the CurrentThread is determined by the Regional Settings of the machine the application is running on.

Kind regards,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Fridli Jacober
Top achievements
Rank 1
answered on 23 Dec 2015, 04:17 PM

Hello

How is this when using the HTML 5 report viewer?

The text box in the filter area always shows "MM/dd/yyyy" and the calendar "Wednesday, December 23, 2015". No matter of the thread culture ("de-CH") or the culture of the report (tested "Standard" or "de-CH").

Help would be appreciated!

Thx & regards

0
Stef
Telerik team
answered on 24 Dec 2015, 02:12 PM
Hello Fridli,

Please, check my post in Report Parameter DateTime Picker Format on UI.

Regards,
Stef
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
0
Fridli Jacober
Top achievements
Rank 1
answered on 24 Feb 2016, 03:21 PM

Thanks Stef!

So to summarize:
Either use Kendo UI globalization (include Kendo culture script and use "kendo.culture("de-CH");")
Or else overwrite one / create your own custom parameter editor?

Does the report culture then still have any influence or does it overwrite the thread's culture (format of culture dependent fields)?

Regards

0
Fridli Jacober
Top achievements
Rank 1
answered on 24 Feb 2016, 03:44 PM
P.S. Is there a possibility to only filter when a filter date is set?
ATM I'm using report filters like "MyUserFunc(Fields.XYZ) >= IsNull(Parameters.DateFrom.Value, "1.1.1900")"
0
Fridli Jacober
Top achievements
Rank 1
answered on 25 Feb 2016, 08:52 AM

Hello

It appears that above filtering approach fails for english browsers. Even though thread's current (UI) culture is set to de / de-CH.
Solved this by using Date(y,m,d) (why is System.DateTime.MinValue not accessible?). But still dates are now presented in english format even though everything in the application / thread is set to (swiss) german.

Is this a bug in Telerik Reporting / HTML 5 viewer / web service, using the browser's language setting (what .NET already does if configured this way) instead of using the thread's culture setting?!? With the WebForms viewer this worked as expected, being able to change the report's language by switching the threads (UI) culture.

Thanks & Regards

0
Fridli Jacober
Top achievements
Rank 1
answered on 25 Feb 2016, 08:56 AM
P.P.S. Tried to explicitly set Culture to "de-CH" in the report itself. Doesn't change anything (obvious).
0
Stef
Telerik team
answered on 26 Feb 2016, 05:44 PM
Hello Fridli,

Reports are processed and rendered on the server. If you use a localization with RESX files (Localizing Reports), in the report's designer.cs(vb) file you can see a standard resource manager that pulls resources from the corresponding RESX file. The RESX file will be determined based on the current thread's culture, which has to be set before creating an instance of the report (before the InitializeComponent method is called).
If youare using the HTML5 Viewer, the current thread's culture can be set on a request e.g.  Localization in ASP.NET MVC 4.

With the above settings you will get the localized strings and the rendered with them report at the client.
In addition, you can localize the UI by using Kendo JS files per language or you can provide custom format in the page.

Please note that if you use a custom format for a widget (via property), the data will not use the format on submit. For example DataTime values can be formatted with slashes, dots and etc. on display, still the object will be transferred as a DateTime object to the server, and the string representation of this object on the server will depend on the server's culture settings; unless the data is transferred as a formatted string.


If you have the following expression in the report:
MyUserFunc(Fields.XYZ) >= IsNull(Parameters.DateFrom.Value, "1.1.1900")
The report must be processed on a machine having culture with default DatetimeFormat like dd.MM.yyyy. Also the IsNull function should return a DateTime object e.g. cast the "1.1.1900" value to Datetime via CDate function.


I hope this information helps.

Regards,
Stef
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
0
Fridli Jacober
Top achievements
Rank 1
answered on 07 Mar 2016, 01:27 PM

Hi Stef

I found out that setting the culture in the Global.asax for the report's localisation basically works the way we do.
The problem is that session is not available at the time of report processing. So the report viewer's thread is in the desired cultures while the thread rendering the report is in the browser's language.
For .ashx I had the same issue. I found out that this can be fixed by implementing "System.Web.SessionState.IReadOnlySessionState" in the .ashx, resulting in the session being available again in Global.asax.

Any suggestions how to achieve this for the thread rendering the report for the HTML 5 viewer?
(User's localization is read once into session at the beginning and is then retrieved from session later)

Thx!

0
Fridli Jacober
Top achievements
Rank 1
answered on 07 Mar 2016, 01:51 PM

Hi Stef

I further followed the steps in the description about HTML 5 report viewer localization. Do I see that right that there's no automisation for this and the viewer's thread's culture doesn't impact the viewer's localisation. Further "kendo.culture("de-CH");" isn't applicable for this and the desired "resources.xyz.js" has to be set/included manually?

Thx & regards

0
Fridli Jacober
Top achievements
Rank 1
answered on 08 Mar 2016, 08:55 AM

P.S.Noticed that the example resource file isn't complete respectively it only contains info and error msgs displayed by the report viewer but no other labels/descriptions of the UI.

- Are there complete samples and / or pre-translated files?
What do you mean by "localize the UI by using Kendo JS files"? Do you have an example for HTML 5 report viewer and / or pre-translated files?

Thx!

0
Stef
Telerik team
answered on 10 Mar 2016, 09:59 AM
Hi Fridli,

In regards to your questions:
  1. Setting the thread's culture:
    This has to be done before creating an instance of the report. If the report uses RESX files, in its InitializeComponent method will be created standard resource manager that takes the corresponding RESX based on the thread's culture.
    Details how to set the culture per request is available in  Localization in ASP.NET MVC 4 (external article).
    In addition, the Reporting REST WebAPi based service is a standard WebAPi controller. If you want to use the current Session in it or in the report's constructor, the Session must be enabled for WebAPI controllers in general - Providing session state in ASP.NET WebAPI (codeproject article)

  2. HTML5 Viewer localization:

    Please check HTML5 Viewer Localization. The added JS file will localize messages displayed by the viewer. If you want to localize the viewer's template, modify the provided viewer's HTML template and set the viewer's templateUrl to point to it instead of loading the default template from the service - Providing Templates.
    There are no ready localized templates for the HTML5 viewer similar to Telerik Kendo UI culture scripts. Since the HTML5 viewer uses Telerik Kendo UI widgets in its template, you can use Telerik Kendo Ui localization for the widgets.


Regards,
Stef
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
0
Fridli Jacober
Top achievements
Rank 1
answered on 18 Mar 2016, 03:37 PM

Hi Stef

Thanks for the articles!

But I still can't get it to work right with Session and WebApi as it seems.
Same place as the reporting resolver I created:

Public Class SessionableControllerHandler
    Inherits Http.WebHost.HttpControllerHandler
    Implements System.Web.SessionState.IRequiresSessionState ' IReadOnlySessionState

    Public Sub New(routeData As RouteData)
        MyBase.New(routeData)
    End Sub
End Class

Public Class SessionStateRouteHandler
    Implements Routing.IRouteHandler

    ' IRouteHandler_GetHttpHandler
    Private Function GetHttpHandler(requestContext As RequestContext) As IHttpHandler Implements IRouteHandler.GetHttpHandler
        Return New SessionableControllerHandler(requestContext.RouteData)
    End Function
End Class

And in Global.asax in Application_Start() I tried:
'RouteTable.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", New With {.id = Http.RouteParameter.Optional}).RouteHandler = New SessionStateRouteHandler()
and
RouteTable.Routes.MapHttpRoute(name:="DefaultApi", routeTemplate:="api/{controller}/{id}", defaults:=New With {Key .id = Http.RouteParameter.[Optional]}).RouteHandler = New SessionStateRouteHandler()

But the report itself appears still in the wrong language / format.

0
Stef
Telerik team
answered on 23 Mar 2016, 03:51 PM
Hi Fridli,

Please check the attached demo project that illustrates how to localize reports and the HTML5 Viewer. The language settings are based on  Localization in ASP.NET MVC 4 (external article).

For more details, please check the links in my previous post.

Regards,
Stef
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
0
Jean
Top achievements
Rank 1
answered on 19 Apr 2017, 03:21 PM

Sure another way, a cookie, it is a good option, i prefer to register telerik web api with /xx/api/Reports, it is like the rest of our application.

It does not resolve the problem when the lang is a parameter of the report !

0
Stef
Telerik team
answered on 20 Apr 2017, 10:18 AM
Hi Fabrice,

The standard localization of reports is based on RESX files and a resource manager that needs the current thread's culture to know which RESX file to be used. Thus the thread's culture must be set before initializing the report.

Report parameters are evaluated to late, after the report is initialized. If you want to localize reports based on a report parameter, then you can create user functions getting a string key of a resource and the report parameter, which functions return the localized string.

Regards,
Stef
Telerik by Progress
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
General Discussions
Asked by
louis chan
Top achievements
Rank 1
Iron
Answers by
Steve
Telerik team
Fridli Jacober
Top achievements
Rank 1
Stef
Telerik team
Jean
Top achievements
Rank 1
Share this question
or