DateTimeGroupDescription in Q2 2013 breaks pivot grid

4 posts, 0 answers
  1. Ke
    Ke avatar
    11 posts
    Member since:
    Mar 2013

    Posted 20 Jun 2013 Link to this post

    Hi There,
    We recently upgraded to Q2 2013 and adding a DateTimeGroupDescription as RowDescription makes the pivotgrid blank.

    Below is the sample code:

    public void UpdatePivotGroups()
    {
        dataProvider.RowGroupDescriptions.Clear();

         foreach (FieldClass field in this.RowGroupDescriptions)
         {
             if (field.DataType == typeof(DateTime))
                 dataProvider.RowGroupDescriptions.Add(GetDateTimeGroupDescription(field));
          }
    }

    public DateTimeGroupDescription GetDateTimeGroupDescription(FieldClass field)
    {
                DateTimeGroupDescription groupDescription = new DateTimeGroupDescription();
               
                groupDescription.Step = DateTimeStep.Day;
                groupDescription.PropertyName = field.FieldID;
                groupDescription.SortOrder = SortOrder.Ascending;
               
                return groupDescription;
      }

    it worked as expected before the dll update. So I am wondering if I need to change the way adding DateTimeGroupDescription.

    Thanks!
  2. Polya
    Admin
    Polya avatar
    199 posts

    Posted 21 Jun 2013 Link to this post

    Hello Ke Jin,

    Thank you for contacting us with your problem. Unfortunatelly, I couldn't reproduce it.
    In order to reproduce it i would have to ask you a few questions: Are you using LocalDataSourceProvider, what is this class you are using to hold RowGroupDescriptions, where do you call UpdatePivotGroups(), do you have nullable DateTime data in your source?

    I created a sample project using LocalDataSourceProvider as data provider and I am calling UpdatePivotGroups() on a ButtonClick event handler. The problem does not occur.
    Can I ask you to reproduce the problem with our application and send it back?


    Regards,
    Polya
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Ke
    Ke avatar
    11 posts
    Member since:
    Mar 2013

    Posted 21 Jun 2013 Link to this post

    Hi Polya,
    Thanks for your quick reply.

    We are using System.Data.DataView as LocalDataSourceProvider.ItemSource instead of the collection you used in your example.

    And I have found the problem is that there are empty DataRows in our DataView. And Q1 2013 can handle that (just display "blank") but Q2 2013 can't. Please see the screenshot where I used Q1 2013.

    I have changed the sample project a little bit to show you where the problem is.  I have added a comment line in the code "this row breaks pivot chart in Q2 2013" so you could easily spot it. I could not attach the whole solution so here's code for MainWindow.xaml.cs

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Telerik.Pivot.Core;

    namespace Ticket707535
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            LocalDataSourceProvider dataProvider;

            public MainWindow()
            {
                InitializeComponent();

                this.dataProvider = new LocalDataSourceProvider();
                this.dataProvider.ItemsSource = GetItemSource();

                this.pivotGrid.DataProvider = this.dataProvider;
                this.pivotFieldList.DataProvider = this.dataProvider;
            }

            public void UpdatePivotGroups()
            {
                dataProvider.RowGroupDescriptions.Clear();

                dataProvider.RowGroupDescriptions.Add(GetDateTimeGroupDescription("Date"));
            }

            public DateTimeGroupDescription GetDateTimeGroupDescription(string date)
            {
                DateTimeGroupDescription groupDescription = new DateTimeGroupDescription();

                groupDescription.Step = DateTimeStep.Year;
                groupDescription.PropertyName = date;
                groupDescription.SortOrder = SortOrder.Ascending;

                return groupDescription;
            }

            private void button_Click_1(object sender, RoutedEventArgs e)
            {
                UpdatePivotGroups();
            }

            private DataView GetItemSource()
            {
                DataTable dataTable = new DataTable();

                DataColumn column1 = new DataColumn("Date", typeof(DateTime));
                DataColumn column2 = new DataColumn("Country", typeof(string));

                dataTable.Columns.Add(column1);
                dataTable.Columns.Add(column2);

                for (int index = 0; index < 5; index++)
                {
                    DataRow newRow = dataTable.NewRow();
                    newRow["Date"] = DateTime.Today.AddYears(index);

                    if (index < 3)
                    {
                        newRow["Country"] = "USA";
                    }
                    else
                    {
                        newRow["Country"] = "China";
                    }

                    dataTable.Rows.Add(newRow);
                }

                DataRow rowToBreakPivot = dataTable.NewRow(); //this row breaks pivot chart in Q2 2013
                dataTable.Rows.Add(rowToBreakPivot);

                // we are using a view in stead of using DataTable directly because we want to apply DataView.RowFilter
                DataView view = new DataView(dataTable); 

                return view;
            }
        }
    }
  5. Polya
    Admin
    Polya avatar
    199 posts

    Posted 24 Jun 2013 Link to this post

    Hello Ke Jin,

    Thank you for reporting this problem and the project you've sent. We've investigated and successfully resolved it.
    The fix will be included in our next internal build.

    I've updated your Telerik Points as a small sign of our appreciation for your efforts. Feel free to contact us in case you have any other problems or concerns.

    Regards,
    Polya
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top