Report Viewer Filter Section Date Format

15 posts, 0 answers
  1. louis chan
    louis chan avatar
    50 posts
    Member since:
    Feb 2010

    Posted 11 Oct 2012 Link to this post

    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.

  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 16 Oct 2012 Link to this post

    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!

  3. DevCraft banner
  4. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 23 Dec 2015 Link to this post

    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

  5. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 24 Dec 2015 Link to this post

    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
  6. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 24 Feb in reply to Stef Link to this post

    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

  7. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 24 Feb in reply to Stef Link to this post

    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")"
  8. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 25 Feb Link to this post

    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

  9. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 25 Feb Link to this post

    P.P.S. Tried to explicitly set Culture to "de-CH" in the report itself. Doesn't change anything (obvious).
  10. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 26 Feb Link to this post

    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
  11. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 07 Mar in reply to Stef Link to this post

    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!

  12. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 07 Mar in reply to Stef Link to this post

    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

  13. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 08 Mar Link to this post

    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!

  14. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 10 Mar Link to this post

    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
  15. Fridli Jacober
    Fridli Jacober avatar
    89 posts
    Member since:
    Dec 2009

    Posted 18 Mar in reply to Stef Link to this post

    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.

  16. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 23 Mar Link to this post

    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
Back to Top
DevCraft banner