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

Formatting of date being ignored and report parameters

5 Answers 462 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 17 Mar 2016, 01:42 PM

I have two problems one being that no matter what i set the report format of a date to be it appears to be ignore when i have setup the propertyes correctly its still displaying the long date, as you can see there is screen shot their.

 

Also how do i pass parameters in the code behind in the html 5 verison in the web form version I would have just done the following.

 

1.Telerik.Reporting.TypeReportSource reportSource = new Telerik.Reporting.TypeReportSource();
2.        reportSource.TypeName = "ApertureNetReport.AdviseCalanderReport, ApertureNetReport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
3.        reportSource.Parameters.Add(new Telerik.Reporting.Parameter("startDate", rdStartDate.SelectedDate.Value));
4.        reportSource.Parameters.Add(new Telerik.Reporting.Parameter("EndDate", rdEndDate.SelectedDate.Value));
5.        bookingReport.ReportSource = reportSource;
6.        bookingReport.Visible = true;

 

 

5 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 22 Mar 2016, 11:54 AM
Hello Philip,

{0:R} format is not applied because the embedded expression {Today()} evaluates the value of a TextBox to a string.

Instead of '{Today()}' you should use the following expression:

= Today()

This will be evaluated as a DateTime value and the required format will be applied.

Regarding your second question, the same approach is valid if you are using HTML5 Report Viewer - How to: Set ReportSource for Report Viewers.
You will need to pass the report source to the viewer's ReportSource.report - HTML5 Report Viewer. The viewer's reportSource consist of report and parameters attributes, where report is the string description of the report that will be displayed, and parameters is a collection of paremeters' keys and values which will be sent to the report.


Regards,
Katia
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
Hesham Desouky
Top achievements
Rank 2
answered on 07 Dec 2016, 10:52 AM

Regarding that expressions of type '{Today()}' not respecting the culture specified to the report. This issue is so irritating and making the report design process very hard. Specially when dealing with HTML boxes.

I wonder why the engine uses the default system culture instead, this is really painful experience.

0
Katia
Telerik team
answered on 09 Dec 2016, 06:13 PM
Hello Hesham,

When using TextBox item the DateTime value should be formatted according to the Culture set for this TextBox or the whole report.

However, when using HtmlTextBox the output will be a not a DateTime. Thus, it will not be formatted as a DateTime value per report's Culture settings.


Regards,
Katia
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
0
Hesham Desouky
Top achievements
Rank 2
answered on 11 Dec 2016, 05:05 PM

Even in Text box, having an expression like "Print Date: " + Today() didn't resoect the culture

Format("{0:d}", Today()) didn't respect the culture

The only way to respect the cultyre is to have the express with Today() expression only

Is this a bug or by design?

0
Katia
Telerik team
answered on 12 Dec 2016, 04:43 PM
Hello Hesham,

When you mix string and function inside the expression the result of the expression will be a not a DateTime. The same applies when using Format() function - it will return a string which cannot be formatted as a DateTime value with respect to the Culture set to the report.

The solution can be to use separate TextBoxes to show the DateTime part and the text part or add a user function for formatting the DateTime values, for example:
public static string formatDate(DateTime date)
        {
            string dateFormatted = date.ToString("ddd d MMM", CultureInfo.CreateSpecificCulture("ar-EG"));
            return dateFormatted;
        }

I hope this information will help.


Regards,
Katia
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
Philip
Top achievements
Rank 1
Answers by
Katia
Telerik team
Hesham Desouky
Top achievements
Rank 2
Share this question
or