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

Date Format issue in Pivot Grid

8 Answers 299 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Shilpa
Top achievements
Rank 1
Shilpa asked on 23 Feb 2016, 06:33 PM

Hi,

 

I have upgraded my telerik version from 2014.2.618.45 to 2015.3.1111.45.

In Previous version i was not facing any date format issue, but in new version if i drop any field of type DateTime to Row/Column Field the date show only Year as value.

I have tried to correct this by using below in  RadPivotGrid1_PreRender(object sender, EventArgs e) :

RadPivotGrid1.Fields[i].DataFormatString = "{0:dd.MM.yyyy}";

 

but it changed the data cell value , not the column,row field value.

 

PFA image for reference.

8 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 24 Feb 2016, 12:43 PM
Hi Shilpa,

It looks like Fields[i] is happened to be the AggregateField, and this is the reason format applies to the aggregates rather than the column headers.

You may want to set the DataFormatString inside the markup declaration of your "Task Last Modified Date" PivotGridColumnField.

If you continue to have the problem, please share with us the markup of your PivotGrid.

Regards,
Vasil
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
Shilpa
Top achievements
Rank 1
answered on 24 Feb 2016, 05:20 PM

Hi Vasil

Below is my Pre_Render function code :

for (int i = 0; i < RadPivotGrid1.Fields.Count; i++)
                {
                    string fieldName = RadPivotGrid1.Fields[i].DataField;
                    if (this.SystemFieldList != null)
                    {
                        SystemFieldView systemFieldList = this.SystemFieldList.FirstOrDefault(q => q.SystemFieldName.Equals(fieldName, StringComparison.OrdinalIgnoreCase));
                        if (systemFieldList != null)
                        {
                            string SystemFieldLabelSearch = systemFieldList.SystemFieldXMLLabelSearch;
                            if (!String.IsNullOrEmpty(SystemFieldLabelSearch))
                            {
                                RadPivotGrid1.Fields[i].Caption = SystemFieldLabelSearch;
                            }
                           
                            //To remove time from datetime

                            foreach (var dateField in this.systemFieldList.Where(q => q.SystemFieldTypeId == 3).Select(q => new { q.SystemFieldName, q.IsTimeDisplayed }).ToArray())
                            {
                                RadPivotGrid1.Fields[i].DataFormatString = "{0:dd.MM.yyyy}";
                            }
                        }
                    }
                }

And I cannot add in markup as these columnare dynamic not static. Attached is my markup code.

0
Vasil
Telerik team
answered on 25 Feb 2016, 12:35 PM
Hi Shilpa,

If you add the fields dynamically, I would suggest you to set the DataFormatString during the FieldCreated event, to be sure it is applied in the correct time of the page lifecycle.

protected void PivotGrid1_FieldCreated(object sender, PivotGridFieldCreatedEventArgs e)
{
    e.Field.DataFormatString = "{0:dd.MM.yyyy}";
}

Regards,
Vasil
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
Shilpa
Top achievements
Rank 1
answered on 01 Mar 2016, 11:48 AM

Hi Vasil,

 

I have added the below code to all three ( RadPivotGrid1_AddingFieldToZone, RadPivotGrid1_FieldCreated and PreRender) functions :

foreach (var dateField in this.SystemFieldList.Where(q => q.SystemFieldTypeId == 3).Select(q => new { q.SystemFieldName, q.IsTimeDisplayed }).ToArray())
            {
                if (e.Field.DataField == dateField.SystemFieldName)
                {
                    e.Field.DataFormatString = "{0:dd.MM.yyyy}";
                }
            }

 

but its not reflecting the correct date format still showing the year only, though at runtime if i debug,the DataFormat as we specify in above code. Attached is the screenshot.

 

Also if i Just tried the static statement for the same it worked (quite surprising), adding screenshot of markup for reference.

 

0
Shilpa
Top achievements
Rank 1
answered on 02 Mar 2016, 11:43 AM
Waiting for response
0
Kostadin
Telerik team
answered on 04 Mar 2016, 10:00 AM
Hi Shilpa,

Could you please let me know how you add the fields to the PivotGrid on the server. Since you have add the PivotGrid declarative you need to add the fields on Page_Load event handler as demonstrated in the following live example. Also could you please try setting the DataFormat string when you create the filed and check whether this will work in your case?

Regards,
Kostadin
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
Shilpa
Top achievements
Rank 1
answered on 07 Mar 2016, 04:19 AM

Hi Kostadin

I bind the datasource in NeedDataSource (which bind the columns selected by user in All Fields section). I don't add the fields in any particular event/function. As per the columns dragged by user in different fields,we save the Pivot settings using RadPersistanceManager.

 

As i mentioned earlier I've tried to set the DataFormatString (depending on the datatype of column) in three methods( RadPivotGrid1_AddingFieldToZone, RadPivotGrid1_FieldCreated and PreRender) but its not working for me.

Also just for information: I've integrated chart with PivotGrid and drilldown functionality implemented.

I really need some solution for this. Thanks in advance.

0
Kostadin
Telerik team
answered on 10 Mar 2016, 06:34 AM
Hi Shilpa,

I prepared a small sample where I add a format string on FieldCreated server event and on my side the format is applied properly. Could you please check out the attached sample and let me know how it differs from your real setup? I would appreciate if you can replicate the issue either in my sample or in a small runnable one in order to investigate it further.

Regards,
Kostadin
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
PivotGrid
Asked by
Shilpa
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Shilpa
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or