Custom Row Height Is Resetting On Sort/Filter

I'm using a sfDataGrid(18.2.0.56) with stacked headers.  The grid body cells are also setup to use text wrapping and so they need dynamic heights calculated.

There are 4 header rows displayed, including the stacked headers I've added explicitly and the inbuilt filtering rows.

On the grid's Loaded event, I'm setting the row height of the first stacked header row to 75 to make it bigger than normal.  This displays perfectly initially, but when I attempted to sort the grid or filter, the height of this row was reset back to it's initial value.

To fix this I modified the height of the first row to 75 in the QueryRowHeight event to ensure it stays correct, and this works fine, but now the data rows with wrapped text then lose their calculated height after filter/sort has taken place.

What I've worked out is that in the QueryRowHeight event, when the grid is first displayed it gets called for all the header rows and the data rows which is perfect.  When I subsequently sort/filter the grid and if I've tried to modify header row 0 to set it to 75, it the QueryRowHeight event never gets called for any of the data rows and they lose their dynamic height. 

If I take out the lines of code in the QueryRowHeight event which try to set the first row to 75, then it always gets called for the data rows, even after a sort/filter.

Any idea what I'm doing wrong?

 <syncfusion:SfDataGrid x:Name="chartAssessmentDataGrid" 
                               ItemsSource="{Binding Pupils}"
                               AutoGeneratingColumn="chartAssessmentDataGrid_AutoGeneratingColumn" 
                               Loaded="chartAssessmentDataGrid_Loaded"
                               QueryRowHeight="chartAssessmentDataGrid_QueryRowHeight"
                               FilterRowPosition="FixedTop"
                               HeaderStyle="{StaticResource headerStyle}"
                               HeaderTemplate="{StaticResource WrappingHeaderTemplate}">

            <syncfusion:SfDataGrid.StackedHeaderRows>
                <syncfusion:StackedHeaderRow>
                    <syncfusion:StackedHeaderRow.StackedColumns>
                        <syncfusion:StackedColumn ChildColumns="FirstName,Surname,ReadingGroup,Class,Gender,TermOfBirth,Ethnicity,HomeLanguage,PPLAC,SEND,Notes"
                                                  HeaderText="Pupil Information" 
                                                  MappingName="PupilInformation"/>
                    </syncfusion:StackedHeaderRow.StackedColumns>
                </syncfusion:StackedHeaderRow>
                <syncfusion:StackedHeaderRow>
                    <syncfusion:StackedHeaderRow.StackedColumns>
                        <syncfusion:StackedColumn ChildColumns="FirstName,Surname,ReadingGroup,Class,Gender,TermOfBirth,Ethnicity,HomeLanguage,PPLAC,SEND,Notes" 
                                                  HeaderText="Key Groups" 
                                                  MappingName="KeyGroups"/>
                    </syncfusion:StackedHeaderRow.StackedColumns>
                </syncfusion:StackedHeaderRow>
            </syncfusion:SfDataGrid.StackedHeaderRows>
        </syncfusion:SfDataGrid>

        private void chartAssessmentDataGrid_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var visualcontainer = chartAssessmentDataGrid.GetVisualContainer();

            visualcontainer.RowHeights[0] = 75;

            visualcontainer.InvalidateMeasure();
        }

        private void chartAssessmentDataGrid_QueryRowHeight(object sender, Syncfusion.UI.Xaml.Grid.QueryRowHeightEventArgs e)
        {
            // If this If statement is included, this event will only get called for header rows after a sort/filter has taken place
            // so the data rows never have their height recalculated and updated by GetAutoRowHeight
            if (e.RowIndex == 0)
            {
                e.Height = 75;
                e.Handled = true;
            }

            if (e.RowIndex > 3)
            {
                double autoHeight = 0;
                if (chartAssessmentDataGrid.GridColumnSizer.GetAutoRowHeight(e.RowIndex, new GridRowSizingOptions { AutoFitMode = AutoFitMode.Default }, out autoHeight))
                {
                    e.Height = autoHeight;
                    e.Handled = true;
                }
            }
        }




1 Reply 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team September 7, 2020 12:36 PM UTC

Hi Wayne, 

Thanks for contacting Syncfusion support.  

We have prepared a sample using stacked header and auto row height customization to replicate your scenario. But unfortunately we are unable to reproduce the reported issue in our end. The sample we have used to check this issue is available in the following link for your reference.  


Please have a look at this sample and let us know if we have missed any customization you have done in your application or try to reproduce the reported issue in this sample and revert to us with the modified sample. It will be more helpful for us to find the exact cause for the issue and to provide a prompt solution at earlier. 

Regards, 
Mohanram A. 



Marked as answer
Loader.
Up arrow icon