TreeGrid allows you to load large amount of data without performance degradation.
To use virtualization, you need to inject VirtualScroll
module in treegrid.
Row virtualization allows you to load and render rows only in the content viewport. It is an alternative way of paging in which the rows will be appended while scrolling vertically. To setup the row virtualization, you need to define
enableVirtualization
as true and content height by height
property.
The number of records displayed in the TreeGrid is determined implicitly by height of the content area and a buffer records will be maintained in the TreeGrid content in addition to the original set of rows.
Expand and Collapse state of any child record will be persisted.
ej.treegrid.TreeGrid.Inject(ej.treegrid.VirtualScroll);
window.dataSource();
var treegrid = new ej.treegrid.TreeGrid({
dataSource: window.virtualData,
enableVirtualization: true,
height: 317,
treeColumnIndex: 1,
childMapping: 'Crew',
columns: [
{ field: 'TaskID', headerText: 'Player Jersey', width: 140, textAlign: 'right' },
{ field: 'FIELD1', headerText: 'Player Name', width: 140 },
{ field: 'FIELD2', headerText: 'Year', width: 120, textAlign: 'right' },
{ field: 'FIELD3', headerText: 'Stint', width: 120, textAlign: 'right' },
{ field: 'FIELD4', headerText: 'TMID', width: 120, textAlign: 'right' }
]
});
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/20.3.47/ej2-base/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-grids/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-popups/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-lists/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-calendars/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-treegrid/styles/material.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/20.3.47/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/20.3.47/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>
.e-treegrid .e-row {
height: 2em;
}
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.