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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfTReeGrid with different row height

Thread ID:

Created:

Updated:

Platform:

Replies:

149550 Nov 29,2019 12:36 PM UTC Dec 3,2019 01:25 PM UTC WPF 3
loading
Tags: SfTreeGrid
Matthias van de Weyer
Asked On November 29, 2019 12:36 PM UTC

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

Mohanram Anbukkarasu [Syncfusion]
Replied On December 2, 2019 12:57 PM UTC

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. 



Matthias van de Weyer
Replied On December 2, 2019 04:00 PM UTC

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



Mohanram Anbukkarasu [Syncfusion]
Replied On December 3, 2019 01:25 PM UTC

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon