Frozen rows and columns provides an option to make rows and columns always visible in the top and left side of the tree grid while scrolling.
To use frozen rows and columns support, inject the Freeze
module in the tree grid.
In this demo, the frozenColumns
is set as ‘2’ and the frozenRows
is set as ‘3’. Hence, the left two columns and top three rows are frozen.
ej.treegrid.TreeGrid.Inject(ej.treegrid.Freeze);
var treegrid = new ej.treegrid.TreeGrid({
dataSource: sampleData,
height: 317,
allowSelection: false,
frozenRows: 3,
frozenColumns: 2,
treeColumnIndex: 1,
childMapping: 'subtasks',
columns: [
{ field: 'taskID', headerText: 'Task ID', textAlign: 'Right', width: 100 },
{ field: 'taskName', headerText: 'Task Name', width: 230 },
{ field: 'startDate', headerText: 'Start Date', width: 120, textAlign: 'Right',
type: 'date', format: { type: 'dateTime', format: 'dd/MM/yyyy' } },
{ field: 'endDate', headerText: 'End Date', width: 120, textAlign: 'Right',
type: 'date', format: { type: 'dateTime', format: 'dd/MM/yyyy' } },
{ field: 'duration', headerText: 'Duration', textAlign: 'Right', width: 110 },
{ field: 'progress', headerText: 'Progress', textAlign: 'Right', width: 120 },
{ field: 'priority', headerText: 'Priority', textAlign: 'Left', width: 120 },
{ field: 'approved', headerText: 'Approved', width: 110, textAlign: 'Left' }
]
});
treegrid.appendTo('#TreeGrid');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 TreeGrid</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript TreeGrid Control">
<meta name="author" content="Syncfusion">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-base/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-grids/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-popups/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-lists/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-calendars/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-treegrid/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
<script src="es5-datasource.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="TreeGrid"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
You can use isFrozen
property to freeze selected columns in tree grid.
In this demo, the columns with field name taskName
and startDate
is frozen using
the isFrozen
property.
ej.treegrid.TreeGrid.Inject(ej.treegrid.Freeze);
var treegrid = new ej.treegrid.TreeGrid({
dataSource: sampleData,
height: 317,
allowSelection: false,
childMapping: 'subtasks',
columns: [
{ field: 'taskID', headerText: 'Task ID', textAlign: 'Right', width: 90 },
{ field: 'taskName', headerText: 'Task Name', width: 230, isFrozen: true },
{ field: 'startDate', headerText: 'Start Date', isFrozen: true, width: 120, textAlign: 'Right',
type: 'date', format: { type: 'dateTime', format: 'dd/MM/yyyy' } },
{ field: 'endDate', headerText: 'End Date', width: 150, textAlign: 'Right',
type: 'date', format: { type: 'dateTime', format: 'dd/MM/yyyy' } },
{ field: 'duration', headerText: 'Duration', textAlign: 'Right', width: 110 },
{ field: 'progress', headerText: 'Progress', textAlign: 'Right', width: 120 },
{ field: 'priority', headerText: 'Priority', textAlign: 'Left', width: 120 },
{ field: 'approved', headerText: 'Approved', width: 110, textAlign: 'Left' }
]
});
treegrid.appendTo('#TreeGrid');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 TreeGrid</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript TreeGrid Control">
<meta name="author" content="Syncfusion">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-base/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-grids/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-popups/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-lists/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-calendars/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-treegrid/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
<script src="es5-datasource.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="TreeGrid"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
You can freeze the tree grid columns on the left or right side by using the column.freeze
property and the remaining columns will be movable. The tree grid will automatically move the columns to the left or right position based on the column.freeze
value.
Types of the column.freeze
directions:
Left
: Allows you to freeze the columns at the left.Right
: Allows you to freeze the columns at the right.In this demo, the Task Name column is frozen at the left and the Priority column is frozen at the right side of the content table.
ej.treegrid.TreeGrid.Inject(ej.treegrid.Freeze);
var treegrid = new ej.treegrid.TreeGrid({
dataSource: sampleData,
height: 317,
treeColumnIndex: 1,
childMapping: 'subtasks',
allowSelection: false,
columns: [
{ field: 'taskID', headerText: 'Task ID', textAlign: 'Right', width: 90 },
{ field: 'taskName', headerText: 'Task Name', width: 230, freeze: 'Left' },
{
field: 'startDate', headerText: 'Start Date', width: 120, textAlign: 'Right',
type: 'date', format: { type: 'dateTime', format: 'dd/MM/yyyy' }
},
{
field: 'endDate', headerText: 'End Date', width: 150, textAlign: 'Right',
type: 'date', format: { type: 'dateTime', format: 'dd/MM/yyyy' }
},
{ field: 'duration', headerText: 'Duration', textAlign: 'Right', width: 110 },
{ field: 'progress', headerText: 'Progress', textAlign: 'Right', width: 120 },
{ field: 'priority', headerText: 'Priority', textAlign: 'Left', freeze: 'Right', width: 120 },
{ field: 'approved', headerText: 'Approved', width: 110, textAlign: 'Left' }
]
});
treegrid.appendTo('#TreeGrid');
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 TreeGrid</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript TreeGrid Control">
<meta name="author" content="Syncfusion">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-base/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-grids/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-popups/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-lists/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-calendars/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-treegrid/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
<script src="es5-datasource.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="TreeGrid"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
- Freeze Direction is not compatible with the
isFrozen
andfrozenColumns
properties.
The following features are not supported in frozen rows and columns:
Freeze Direction feature has the below limitations, along with the above mentioned limitations.
You can refer to our
JavaScript Tree Grid
feature tour page for its groundbreaking feature representations. You can also explore our JavaScript tree grid exampleJavaScript Tree Grid example
to knows how to present and manipulate data.