Frozen in Vue Treegrid component

11 Jun 202417 minutes to read

Frozen rows and columns

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 provide section.

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.

<template>
    <div id="app">
        <ejs-treegrid :dataSource='data' childMapping='subtasks' :treeColumnIndex='1' height=310 :frozenColumns='2' :frozenRows='3' :allowSelection='false'>
            <e-columns>
               <e-column field='taskID' headerText='Task ID' width='110' textAlign='Right'></e-column>
                <e-column field='taskName' headerText='Task Name' width='230'></e-column>
                <e-column field='startDate' headerText='Start Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='endDate' headerText='End Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='duration' headerText='Duration' width='110' textAlign='Right'></e-column>
                <e-column field='progress' headerText='Progress' width='120' textAlign='Right'></e-column>
                <e-column field='priority' headerText='Priority' width='120'></e-column>
                <e-column field='approved' headerText='Approved' width='110' textAlign='Left'></e-column>
            </e-columns>
        </ejs-treegrid>
    </div>
</template>
<script setup>
import { provide } from "vue";

import { TreeGridComponent as EjsTreegrid, Freeze, ColumnDirective as EColumn, ColumnsDirective as EColumns } from "@syncfusion/ej2-vue-treegrid";
import { sampleData } from "./datasource.js";

const data = sampleData;

provide('treegrid',  [Freeze]);

</script>
<template>
    <div id="app">
        <ejs-treegrid :dataSource='data' childMapping='subtasks' :treeColumnIndex='1' height=310 :frozenColumns='2' :frozenRows='3' :allowSelection='false'>
            <e-columns>
               <e-column field='taskID' headerText='Task ID' width='110' textAlign='Right'></e-column>
                <e-column field='taskName' headerText='Task Name' width='230'></e-column>
                <e-column field='startDate' headerText='Start Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='endDate' headerText='End Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='duration' headerText='Duration' width='110' textAlign='Right'></e-column>
                <e-column field='progress' headerText='Progress' width='120' textAlign='Right'></e-column>
                <e-column field='priority' headerText='Priority' width='120'></e-column>
                <e-column field='approved' headerText='Approved' width='110' textAlign='Left'></e-column>
            </e-columns>
        </ejs-treegrid>
    </div>
</template>
<script>

import { TreeGridComponent, Freeze, ColumnDirective, ColumnsDirective } from "@syncfusion/ej2-vue-treegrid";
import { sampleData } from "./datasource.js";

export default {
name: "App",
components: {
"ejs-treegrid":TreeGridComponent,
"e-columns":ColumnsDirective,
"e-column":ColumnDirective,

},

  data() {
    return {
      data: sampleData
    };
  },
  provide: {
    treegrid: [Freeze]
  }
}
</script>

Freeze particular columns

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.

<template>
    <div id="app">
        <ejs-treegrid :dataSource='data' childMapping='subtasks' height=310  :allowSelection='false'>
            <e-columns>
               <e-column field='taskID' headerText='Task ID' width='90' textAlign='Right'></e-column>
                <e-column field='taskName' headerText='Task Name' width='230' isFrozen='true'></e-column>
                <e-column field='startDate' headerText='Start Date' isFrozen='true' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='endDate' headerText='End Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='duration' headerText='Duration' width='110' textAlign='Right'></e-column>
                <e-column field='progress' headerText='Progress' width='120' textAlign='Right'></e-column>
                <e-column field='priority' headerText='Priority' width='120'></e-column>
                <e-column field='approved' headerText='Approved' width='110' textAlign='Left'></e-column>
            </e-columns>
        </ejs-treegrid>
    </div>
</template>
<script setup>
import { provide } from "vue";

import { TreeGridComponent as EjsTreegrid, Freeze, ColumnDirective as EColumn, ColumnsDirective as EColumns } from "@syncfusion/ej2-vue-treegrid";
import { sampleData } from "./datasource.js";

const data = sampleData;

provide('treegrid',  [Freeze]);

</script>
<template>
    <div id="app">
        <ejs-treegrid :dataSource='data' childMapping='subtasks' height=310  :allowSelection='false'>
            <e-columns>
               <e-column field='taskID' headerText='Task ID' width='90' textAlign='Right'></e-column>
                <e-column field='taskName' headerText='Task Name' width='230' isFrozen='true'></e-column>
                <e-column field='startDate' headerText='Start Date' isFrozen='true' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='endDate' headerText='End Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='duration' headerText='Duration' width='110' textAlign='Right'></e-column>
                <e-column field='progress' headerText='Progress' width='120' textAlign='Right'></e-column>
                <e-column field='priority' headerText='Priority' width='120'></e-column>
                <e-column field='approved' headerText='Approved' width='110' textAlign='Left'></e-column>
            </e-columns>
        </ejs-treegrid>
    </div>
</template>
<script>

import { TreeGridComponent, Freeze, ColumnDirective, ColumnsDirective } from "@syncfusion/ej2-vue-treegrid";
import { sampleData } from "./datasource.js";

export default {
name: "App",
components: {
"ejs-treegrid":TreeGridComponent,
"e-columns":ColumnsDirective,
"e-column":ColumnDirective,

},

  data() {
    return {
      data: sampleData
    };
  },
  provide: {
    treegrid: [Freeze]
  }
}
</script>

Freeze direction

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.

<template>
    <div id="app">
        <ejs-treegrid :dataSource='data' childMapping='subtasks' height=310 :treeColumnIndex='1'  :allowSelection='false'>
            <e-columns>
               <e-column field='taskID' headerText='Task ID' width='90' textAlign='Right'></e-column>
                <e-column field='taskName' headerText='Task Name' width='230' freeze='Left'></e-column>
                <e-column field='startDate' headerText='Start Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='endDate' headerText='End Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='duration' headerText='Duration' width='110' textAlign='Right'></e-column>
                <e-column field='progress' headerText='Progress' width='120' textAlign='Right'></e-column>
                <e-column field='priority' headerText='Priority' width='120' freeze='Right'></e-column>
                <e-column field='approved' headerText='Approved' width='110' textAlign='Left'></e-column>
            </e-columns>
        </ejs-treegrid>
    </div>
</template>
<script setup>
import { provide } from "vue";

import { TreeGridComponent as EjsTreegrid, Freeze, ColumnsDirective as EColumns, ColumnDirective as EColumn } from "@syncfusion/ej2-vue-treegrid";
import { sampleData } from "./datasource.js";

const data = sampleData;

provide('treegrid',  [Freeze]);

</script>
<template>
    <div id="app">
        <ejs-treegrid :dataSource='data' childMapping='subtasks' height=310 :treeColumnIndex='1'  :allowSelection='false'>
            <e-columns>
               <e-column field='taskID' headerText='Task ID' width='90' textAlign='Right'></e-column>
                <e-column field='taskName' headerText='Task Name' width='230' freeze='Left'></e-column>
                <e-column field='startDate' headerText='Start Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='endDate' headerText='End Date' width='120' format="yMd" textAlign='Right'></e-column>
                <e-column field='duration' headerText='Duration' width='110' textAlign='Right'></e-column>
                <e-column field='progress' headerText='Progress' width='120' textAlign='Right'></e-column>
                <e-column field='priority' headerText='Priority' width='120' freeze='Right'></e-column>
                <e-column field='approved' headerText='Approved' width='110' textAlign='Left'></e-column>
            </e-columns>
        </ejs-treegrid>
    </div>
</template>
<script>

import { TreeGridComponent, Freeze, ColumnDirective, ColumnsDirective } from "@syncfusion/ej2-vue-treegrid";
import { sampleData } from "./datasource.js";

export default {
name: "App",
components: {
"ejs-treegrid":TreeGridComponent,
"e-columns":ColumnsDirective,
"e-column":ColumnDirective,

},

  data() {
    return {
      data: sampleData
    };
  },
  provide: {
    treegrid: [Freeze]
  }
}
</script>

Limitations of frozen tree grid

The following features are not supported in frozen rows and columns:

  • Row Template
  • Detail Template
  • Cell Editing

Freeze Direction feature has the below limitations, along with the above mentioned limitations.

  • Infinite scroll cache mode
  • Freeze direction in the stacked header is not compatible with column reordering.