Date Format issue in Pivot Grid

9 posts, 0 answers
  1. Shilpa
    Shilpa avatar
    29 posts
    Member since:
    Apr 2015

    Posted 23 Feb Link to this post

    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.

  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 24 Feb Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shilpa
    Shilpa avatar
    29 posts
    Member since:
    Apr 2015

    Posted 24 Feb in reply to Vasil Link to this post

    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.

  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 25 Feb Link to this post

    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
  6. Shilpa
    Shilpa avatar
    29 posts
    Member since:
    Apr 2015

    Posted 01 Mar Link to this post

    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.

     

  7. Shilpa
    Shilpa avatar
    29 posts
    Member since:
    Apr 2015

    Posted 02 Mar Link to this post

    Waiting for response
  8. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 04 Mar Link to this post

    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
  9. Shilpa
    Shilpa avatar
    29 posts
    Member since:
    Apr 2015

    Posted 06 Mar Link to this post

    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.

  10. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 10 Mar Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017