Scrolling in TypeScript Treegrid control
18 Nov 20181 minute to read
The scrollbar will be displayed in the treegrid when content exceeds the element width or height. The vertical and horizontal scrollbars will be displayed based on the following criteria:
- The vertical scrollbar appears when the total height of rows present in the treegrid exceeds its element height.
- The horizontal scrollbar appears when the sum of columns width exceeds the treegrid element width.
- The
heightandwidthare used to set the treegrid height and width, respectively.
Set width and height
To specify the width and height of the scroller in the pixel, set the pixel value to a number.
Responsive with parent container
Specify the width and height as 100% to make the treegrid element fill its parent container.
Setting the height to 100% requires the treegrid parent element to have explicit height.
Sticky header
The Syncfusion TypeScript TreeGrid provides a useful feature to keep the column headers fixed (sticky) while scrolling through large datasets. This ensures that the headers remain visible at all times, enhancing user experience by making it easier to understand the context of the data displayed, especially when dealing with wide or long hierarchical data.
For example, in a project management application, users often need to scroll through a detailed list of tasks and subtasks. When the dataset is large, scrolling down can cause confusion if the column headers scroll out of view, making it difficult to remember what each column represents. By enabling sticky headers, the column headers remain visible even while scrolling, allowing users to easily keep track of the data context.
To enable sticky headers in the TreeGrid, you can simply set the enableStickyHeader property to true. This makes the column headers stick to the top of the TreeGrid container or its parent scrolling container when you scroll vertically.
The following sample demonstrates how to enable or disable the sticky header in the TreeGrid using a Switch and its change event:
Scroll to selected row
You can scroll the treegrid content to the selected row position by using the rowSelected event.