Welcome to the Xceed Community | Help
Community Search  
More Search Options

Performance, combo box & change detection issues (among others)

Sort Posts: Previous Next
  •  07-08-2010, 5:18 PM Post no. 27456

    Performance, combo box & change detection issues (among others)

     

    Hello,

    I have a few questions/problems in regards to the WPF datagrid. I am evaluating your program and we are ready to buy it if I can solve these little problems. I created a sample originally based on your sample LargeDataSets. My real application currently uses Xceed grids (winform). We want to change to datagrid WPF mostly because of performances issues, of uniformity with the rest of our application and for some nice features (i.e. the data filters). Our grid have a lot of rows (for now it ranges at around 100 000 lines) and about 20 to 60 columns.

    I will send you a sample application through email in a few minutes (support@xceed.com).

    1- I am concerned about performances. Scrolling is great, but if there is a group (i.e.FamilyId) the sorting is really, really slow (the grid freezes for several minutes). Do you have any suggestions about improving performances? I would like to start on good basics and that freeze is not acceptable.

    2- Since we have a huge amount of columns, is it possible to have sub menus in the columns chooser or does it have to be fully custom made?

    3- I would like to detect changes as soon as edit begun in order to activate an “Apply” button (in my sample it is just a checkbox). By example, I want to detect changes as soon as the user started typing, not when he exited the cell (like it is now). I am listening to dataTable.RowChanged and I am using UpdateSourceTrigger=”CellContentChanged”but it doesn’t seem to change anything.  

    4- I used to be bound to an ObservableList. Since I switched to DataTable, the “LineType” column (with combo box in edit mode) doesn’t display the text anymore. SelectedItem="{xcdg:CellEditorBinding}" never seemed to work (the selected value in edit mode doesn’t show the selection). 

    5- Do you have any suggestions about merging 2 data types? In my sample, I have a food that references a family. When displaying foods in my grid, instead of displaying “FamilyId”, I would like to display its name, description and address in 3 different columns. All my data is loaded in memory and stored in lists by data type (i.e. IList<Food> & IList<Family>). It comes from a database but to avoid database requests, everything is in memory. 

    6- Text wrapping in view mode doesn’t work. I use:

    <Style TargetType="{x:Type xcdg:Column}">

        <Setter Property="TextWrapping"Value="Wrap" />

    </Style>

    Thank you very much,

    Marie 

     

    Note: DataGridxaml:

    <xcdg:DataGridControlx:Name="grid"

                            ItemScrollingBehavior="Immediate"

                            Grid.Row="0"

                            Grid.RowSpan="2"

                            IsDeleteCommandEnabled="True"

                            UpdateSourceTrigger="CellContentChanged"

                            ItemsSource="{Binding Source={StaticResource cvs_objects}}">

        <xcdg:DataGridControl.Columns>

            <xcdg:Column FieldName="LineType">

                <xcdg:Column.CellEditor>

                    <xcdg:CellEditor>

                        <xcdg:CellEditor.EditTemplate>

                            <DataTemplate>

                                <ComboBoxItemsSource="{Binding RelativeSource={RelativeSourceFindAncestor,AncestorType=local:MainPage},

                                                               Path=LineTypeValues}"

                                            SelectedItem="{xcdg:CellEditorBinding}"/>

                            </DataTemplate>

                        </xcdg:CellEditor.EditTemplate>

                    </xcdg:CellEditor>

                </xcdg:Column.CellEditor>

            </xcdg:Column>

        </xcdg:DataGridControl.Columns>

        <xcdg:DataGridControl.Resources>

            <Style TargetType="{x:Type xcdg:TableView}">

                <SetterProperty="AllowColumnChooser" Value="True" />

                <SetterProperty="IsAlternatingRowStyleEnabled" Value="True" />

            </Style>

            <Style TargetType="{x:Type xcdg:AutoSelectTextBox}">

                <SetterProperty="SpellCheck.IsEnabled" Value="True" />

                <SetterProperty="Language" Value="en" />

                <SetterProperty="TextWrapping" Value="Wrap" />

                <SetterProperty="AcceptsReturn" Value="True" />

            </Style>

            <Style TargetType="{x:Type xcdg:Column}">   <!--TODO Text wrapping does notwork...-->

                <SetterProperty="TextWrapping" Value="Wrap" />

            </Style>

        </xcdg:DataGridControl.Resources>

    </xcdg:DataGridControl>

     

  •  07-09-2010, 2:14 PM Post no. 27474 in reply to 27456

    Re: Performance, combo box & change detection issues (among others)

    Hi,

    Here are the answers to your questions:

    1- I do not see an issue in performance when sorting by the FamilyId field. What is the version of the assembly being used?

    2- You will have to redo you own control. You will have to make sure to put the property "AllowColumnChooser" to false on the view in order to be able to put you own control.

    3- The RowChanged event is raised when a row is done being edited. Not when one of its cells is edited. I would suggest handling the EditBegun, EditEnded, and EditCanceled methods to handle this scenario. For example:

                     
                        <Style TargetType="{x:Type xcdg:DataCell}">
                            <EventSetter Handler="DataCell_EditBegun"
                                        Event="xcdg:DataCell.EditBegun"/>
                            <EventSetter Handler="DataCell_EditCanceled"
                                        Event="xcdg:DataCell.EditCanceled"/>
                            <EventSetter Handler="DataCell_EditEnded"
                                        Event="xcdg:DataCell.EditEnded"/>
                        </Style>



          private void DataCell_EditBegun( object sender, RoutedEventArgs e )
          {
            DataChangedCheckBox.IsChecked = true;
          }

          private void DataCell_EditCanceled( object sender, RoutedEventArgs e )
          {
            if( m_dirty )
              return;

            DataChangedCheckBox.IsChecked = false;
          }

          private bool m_dirty = false;
          private void DataCell_EditEnded( object sender, RoutedEventArgs e )
          {
            DataCell cell = sender as DataCell;

            if( cell == null )
              return;

            if( cell.IsDirty )
              m_dirty = true;
          }


    4-  For this problem, it seems that there is a bug in the converter of our grid that does not seem to be able to convert from Int32 to your enum. Indeed, despite the fact that in the DataTable, the type of the column "LineType", has been defined to the type of the enum, the DataTable returns an Int32 as the value.

    We managed to solve the problem by doing the folowing:
    - The property "MainPage.LineTypeValues" must return an array of  LineType (LineType[]).
    - We must specify a Converter on the ItemProperty of the property on the CollectionViewSource which is defined in the file "AuxiliaryResources.xaml".

      <xcdg:DataGridCollectionViewSource x:Key="cvs_objects"
                                          Source="{Binding Path=DataTable}"
                                          AutoFilterMode="And">
          <xcdg:DataGridCollectionViewSource.ItemProperties>
            <xcdg:DataGridItemProperty Name="LineType"
                                        Converter="{x:Static local:EnumToIntValueConverter.Singleton}" />
          </xcdg:DataGridCollectionViewSource.ItemProperties>
      </xcdg:DataGridCollectionViewSource>

    We did a very simple implementation of ValueConverter. Here is the code of the converter:

      public class EnumToIntValueConverter : IValueConverter
      {
        public static EnumToIntValueConverter Singleton = new EnumToIntValueConverter();

        #region IValueConverter Members

        public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
          if( value != null )
          {
            try
            {
              return ( FoodDataProvider.LineType )value;
            }
            catch { }
          }

          return null;
        }

        public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
          if( value != null )
          {
            try
            {
              return ( int )value;
            }
            catch { }
          }

          return null;
        }

        #endregion
      }


    5- I think you can use an ICustomTypeDescriptor to fulfill your requirements.

    6- Can't create a style that targets column. The TextTrimming property will need to be defined on each column.

     

    Regards,

    Alain Jreij,

    Web Developer,

    Xceed Software Inc
  •  07-12-2010, 8:53 AM Post no. 27494 in reply to 27474

    Re: Performance, combo box & change detection issues (among others)

    Hi Alain, 

    Thanks a lot for your answers  :)

    1- It is not sorting that has performance problems. Sorting by itself works like a charm. Try grouping by FamilyId (or anything else) and then sorting by Age (or anything else). The grid freezes for a long time (minutes?). I am using a trial version of Xceed (I got from your website 30 days ago). Xceed.Wpf.Controls, Xceed.Wpf.DataGrid and Xceed.Wpf.DataGrid.ThemePack.3 version 3.7.10226.11110.

    I'll try the rest of your answers later on today. Thanks again!

    Regards,

    Marie 

     

  •  07-12-2010, 1:11 PM Post no. 27499 in reply to 27494

    Re: Performance, combo box & change detection issues (among others)

    Hi Marie,

    For 1), we could not reproduce the freezing.

    Would it be possible to send us a small sample application that reproduces the freezing so that we can identify its causes?

     


    Regards,

    Alain Jreij,

    Web Developer,

    Xceed Software Inc
  •  07-12-2010, 1:18 PM Post no. 27501 in reply to 27499

    Re: Performance, combo box & change detection issues (among others)

    Hi Alain,

    The sample I sent you on Thursday reproduces the problem. If you don't have it anymore, just tell me and I will re-send it to you.

    To reproduce it, just run the TestWPFXceed_LargeDataSets project, create a group and sort. It freezes for several minutes. If you wait, eventually it will unfreeze. I don't know if it changes anything, but I have a 64 bits machine running Windows 7 (but the application itself is set to be 32 bits).

    Thank you,
    Marie 

  •  07-12-2010, 2:36 PM Post no. 27503 in reply to 27501

    Re: Performance, combo box & change detection issues (among others)

    Hi Marie,

    I could not reproduce the freezing using your sample. The sorting works fine with or without grouping.

    I also am running a Win 7 64 bits machine.


    Regards,

    Alain Jreij,

    Web Developer,

    Xceed Software Inc
  •  07-12-2010, 5:20 PM Post no. 27505 in reply to 27503

    Re: Performance, combo box & change detection issues (among others)

    Hello Alain,

    Do you have any suggestions on what could cause that slowdown? 

    I tried my sample application on someone's else machine and the same problem occured. I read somewhere in the forum for some other performance problem that the graphic card might be problematic. I am using NVIDIA GeForce GTX 260 with latest drivers (8.17.11.9621).

    In case there are more than one ways to do this, here are the exact reproduction steps:

    1) Install Xceed DataGrid WPF for .Net Framework 3.5 (3.7) and unrar the rar I sent you.

    2) Open TestWPFXceed_LargeDataSets.sln (it will open it in Visual Studio 2010)

    3) Make sure all the references are fine (on my coworker's machine the "Xceed.Wpf.DataGrid.ThemPack.3" reference was broken for some reason).

    4) Compile & launch the application (TestWPFXceed_LargeDataSets should already be the startup project).

    5) Wait a bit (the data loads) 

    6)  Drag & Drop the "FamilyId" header in the "Drag a column header here to group by that column." section

    7) Wait a bit while the data gets grouped (really short)

    8)  Click on "Age" (on the "Age header").

    9) Wait for several minutes while the sorting takes place (The grid and entire application are frozen). 

     

    Thanks,

    Marie 

  •  07-14-2010, 2:28 PM Post no. 27533 in reply to 27505

    Re: Performance, combo box & change detection issues (among others)

    Hi Marie,

    Disregard my previous reply, we managed to reproduce the freezing issue.

    In your case, you have ~100000 items. When we group by the field "FamilyId", you will end up with groups with 3 to 5 items; in this situation, the grid must make a sort-by-group, which will greatly impact the UI performance.

    So, to conclude, this issue is considered as somewhat a normal behavior from our part and not a bug.


    Regards,

    Alain Jreij,

    Web Developer,

    Xceed Software Inc
  •  07-14-2010, 5:21 PM Post no. 27537 in reply to 27533

    Re: Performance, combo box & change detection issues (among others)

    Hi Alain,

    Thanks a lot for your answer. However, this is not acceptable for us... Because even with 30 000 items, there is still a quite long freeze. Furthermore, with your sample, we waited over 1 hour and the table was still frozen...

    Do you think there is something you (or I) could do about this?

    I tried to do my own little test that sorts all items from all groups that have more than 1 item in them. When I do so (without painting), it takes less than 1 seconds to do:

     private void TestSortButtonClick(object sender, RoutedEventArgs e)

    {

        Stopwatch stopWatch = new Stopwatch();

        stopWatch.Start();


        int groupsSkipped = 0;

        int groupsSorted = 0;

        DataGridCollectionView dataGridCollectionView = (DataGridCollectionView)grid.ItemsSource;

        foreach (CollectionViewGroup group in dataGridCollectionView.Groups)

        {

            if (group.GetItemCount() <= 1)

            {

                groupsSkipped++;

                continue;

            }

            List<object> list = new List<object>(group.GetItems());

            list.Sort(new DataRowViewComparer());

            groupsSorted++;

        }


        stopWatch.Stop();

        // Get the elapsed time as a TimeSpan value.

        TimeSpan ts = stopWatch.Elapsed;


        MessageBox.Show(string.Format("Sort time: {0}.\nGroups sorted: {1}\nGroups skipped: {2}", +ts, groupsSorted, groupsSkipped),

            "Sort time elapsed");

    }

     public class DataRowViewComparer : IComparer<object>

    {

        public int Compare(object x, object y)

        {

            DataRowView row1;

            DataRowView row2;


            if (x is DataRowView)

                row1 = x as DataRowView;

            else

                throw new ArgumentException("Object is not of type DataRowView.");


            if (y is DataRowView)

                row2 = y as DataRowView;

            else

                throw new ArgumentException("Object is not of type DataRowView.");


            return row1["Age"].ToString().CompareTo(row2["Age"].ToString());

        }

    }

     

    Could the huge delays be caused by painting? Is there a way to catch when the sorting begins and when it ends to stop triggering refreshes during that time? Do you have any other ideas?

    Thank you,

    Marie 

  •  07-25-2010, 5:39 PM Post no. 27705 in reply to 27537

    Re: Performance, combo box & change detection issues (among others)

    Update for information purposes:

    This case was continued through email support. A fix request was submitted to the development team to investigate further, and a correction has been made. The fix will be included in the next service release (in 4-6 weeks).



    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.