We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfTReeGrid with different row height

Hello;

I'm trying two implement a SfTreeGrid with differnent sized rows. Unfortunately i'm not getting it to work.
I found a feature request for autmatic row sizing. This would help me as well, but a way of adjusting the height manually would be enough.

I've tried different things.

- Setting "TextWrapping" to true in the TemplateColumn didn't work
- Defining the height for the templated control didn't work.
- Using the TreeGridRowGenerator to adjust the height of the FrameworkElement yielded a strange behaviour. It looks like the size has changed, but the rest of the tree grid is not refreshed. So the text and borders of the cell are no longer visible, because they move "behind" the next cell.  I've tried to call all invalidate meethods, that I could find but the result stays the same.

Is there any way of defining different row heights in an SfTreeGrid?

Thanks in advance

Matthias

3 Replies

MA Mohanram Anbukkarasu Syncfusion Team December 2, 2019 04:57 AM

Hi Matthias, 

Thanks for Contacting Syncfusion support.  

You can change the row height for a specific row in TreeGrid as shown in the following code example. 

Code example

this.treeGrid.Loaded += OnTreeGrid_Loaded; 
 
private void OnTreeGrid_Loaded(object sender, RoutedEventArgs e) 
{ 
    this.treeGrid.GetTreePanel().RowHeights[1] = 50; 
    this.treeGrid.UpdateDataRow(1); 
} 


Please let us know if your require further assistance from us.  

Regards, 
Mohanram A. 




MV Matthias van de Weyer December 2, 2019 08:00 AM

Hi Mohanram,

thank you for your assistance, this brings me one step further.
Unfortunately I have to bother you again.

I was now trying to update the row heights in the NodeExpanded event. I would like to meassure the cell content, to fit the height to the content. But I can't find a way to match the row index and the related FrameworkElement (i.e. TreeGridRowControl).

This is what i've tried:

        private void NodeExpandedHandler(object sender, NodeExpandedEventArgs e)
        {
            IPaddedEditableLineSizeHost rowHeights = treeView.GetTreePanel().RowHeights;
            TreeGridRowGenerator rowGenerator = treeView.GetTreeGridRowGenerator();
            foreach (TreeNode treeNode in e.Node.ChildNodes)
            {
                int rowIndex = treeView.ResolveToRowIndex(treeNode);

                rowHeights[rowIndex] = 50;
                treeView.UpdateDataRow(rowIndex);

                // Yields the wrong row (next row before expanding)
                TreeDataRowBase row = rowGenerator.Items[rowIndex];

                // row does not (yet) exist (null)
                var test3 = treeView.GetTreeDataColumnBase(new RowColumnIndex(rowIndex, 2));
            }
        }

It seems like the expand operation is not fully completed, when the event is fired.
Is there a better way to achieve this behavior?
Is there something like a "RowDisplayedEvent"

Thanks again,
Matthias




MA Mohanram Anbukkarasu Syncfusion Team December 3, 2019 05:25 AM

Hi Matthias, 

Thanks for the update.  

SfTreeGrid doesn’t have any event like RowDisplayed as you mentioned. If possible could you please share your runnable application? Otherwise please share the details about how you are measuring the cell content  and about the columns defined in the DataGrid with code snippet and a screenshot of your application. These details will be helpful for us to check and provide a prompt solution for your requirement.  

Regards, 
Mohanram A. 


Loader.
Live Chat Icon For mobile
Up arrow icon