Column Pinning (Frozen) in Vue Grid component
11 Jun 202424 minutes to read
In the Syncfusion Vue Grid component, you have the capability to freeze columns, ensuring they remain visible as you scroll through extensive datasets. This functionality significantly improves user experience by keeping critical information constantly within view, even when navigating through large volumes of data. This means that important columns remain fixed in their positions, making it easier to access and reference key data points while working with the grid.
In the following example, the frozenColumns property is set to 2. This configuration freezes the left two columns of the grid, and they will remain fixed in their positions while the rest of the columns grid can be scrolled horizontally.
<template>
<div id="app">
<div style="display: inline-block;">
<label> Change the frozen columns: </label>
<ejs-numerictextbox ref='textbox' id='textbox' :min="0" :max="3" :validateDecimalOnType="true" floatLabelType="Auto" format="n" width='100px' :value=2></ejs-numerictextbox>
<ejs-button ref='button' cssClass='e-outline' v-on:click="frozenColumnFn">Update</ejs-button>
</div>
<ejs-grid ref='grid' style="padding: 5px 5px" :dataSource="data" height='315px' :frozenColumns='2' :enableHover='false'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=100></e-column>
<e-column field='OrderDate' headerText='Order Date' width=100 format='yMd' textAlign='Right'></e-column>
<e-column field='EmployeeID' headerText='Employee ID' textAlign='Right' width=80></e-column>
<e-column field='ShipName' headerText='Ship Name' width=130></e-column>
<e-column field='ShipAddress' headerText='Ship Address' width=140></e-column>
<e-column field='ShipCity' headerText='Ship City' width=100></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width=100></e-column>
<e-column field='ShipRegion' headerText='Ship Region' width=80></e-column>
<e-column field='ShipPostalCode' headerText='Ship Postal Code' width=110></e-column>
<e-column field='Freight' headerText='Freight' width=80></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script setup>
import { provide, ref } from "vue";
import { GridComponent as EjsGrid, ColumnDirective as EColumn, ColumnsDirective as EColumns, Freeze } from "@syncfusion/ej2-vue-grids";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
import { NumericTextBoxComponent as EjsNumerictextbox } from '@syncfusion/ej2-vue-inputs';
import { data } from './datasource.js';
const grid = ref(null);
const frozenColumnFn = function() {
grid.value.frozenColumns = this.$refs.textbox.$el.value;
}
provide('grid', [Freeze]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-calendars/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/tailwind.css";
</style>
<template>
<div id="app">
<div style="display: inline-block;">
<label> Change the frozen columns: </label>
<ejs-numerictextbox ref='textbox' id='textbox' :min="0" :max="3" :validateDecimalOnType="true" floatLabelType="Auto" format="n" width='100px' :value=2></ejs-numerictextbox>
<ejs-button ref='button' cssClass='e-outline' v-on:click="frozenColumnFn">Update</ejs-button>
</div>
<ejs-grid ref='grid' style="padding: 5px 5px" :dataSource="data" height='315px' :frozenColumns='2' :enableHover='false'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=100></e-column>
<e-column field='OrderDate' headerText='Order Date' width=100 format='yMd' textAlign='Right'></e-column>
<e-column field='EmployeeID' headerText='Employee ID' textAlign='Right' width=80></e-column>
<e-column field='ShipName' headerText='Ship Name' width=130></e-column>
<e-column field='ShipAddress' headerText='Ship Address' width=140></e-column>
<e-column field='ShipCity' headerText='Ship City' width=100></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width=100></e-column>
<e-column field='ShipRegion' headerText='Ship Region' width=80></e-column>
<e-column field='ShipPostalCode' headerText='Ship Postal Code' width=110></e-column>
<e-column field='Freight' headerText='Freight' width=80></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import { GridComponent, ColumnsDirective, ColumnDirective, Freeze } from "@syncfusion/ej2-vue-grids";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
import { NumericTextBoxComponent } from '@syncfusion/ej2-vue-inputs';
import { data } from './datasource.js';
export default {
name: "App",
components: {
"ejs-numerictextbox":NumericTextBoxComponent,
"ejs-button":ButtonComponent,
"ejs-grid":GridComponent,
"e-columns":ColumnsDirective,
"e-column":ColumnDirective
},
data() {
return {
data: data
};
},
methods: {
frozenColumnFn: function() {
this.$refs.grid.frozenColumns = this.$refs.textbox.$el.value;
}
},
provide: {
grid: [Freeze]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-calendars/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/tailwind.css";
</style>
- Frozen columns should not be set outside the grid view port.
- Frozen Grid support column virtualization feature, which helps to improve the Grid performance while loading a large dataset.
- The frozen feature is supported only for the columns that are visible in the current view.
- You can use both
frozenColumns
property and frozenRows property in the same application.
Freeze particular columns
The Syncfusion Vue Grid provides a valuable feature that enables you to freeze specific columns, significantly enhancing data visibility and improving your overall user experience. This functionality allows you to select particular columns and freeze them by positioning them at the leftmost side of the grid, ensuring they remain fixed in place while the remaining grid columns can still be scrolled horizontally. While the frozenColumns
property freezes columns in the order they are initialized in the grid, you can also use the isFrozen
property at the column level to freeze a specific column at any desired index on the left side, offering flexibility in managing which columns are frozen.
To freeze a particular column in the grid, you can utilize the isFrozen property of the grid component as true.
The following example demonstrates how to freeze particular column in grid using isFrozen
property. This is achieved by the change event of the DropDownList
component. Within the change event, you can modify the isFrozen
property of the selected column using the getColumnByField method. Afterward, you can use the refreshColumns method to update the displayed columns based on your interaction.
<template>
<div id="app">
<div style="display: inline-block;">
<label> Change the frozen column: </label>
<ejs-dropdownlist id='dropdownlist' :dataSource='dropDownData' index="0" :change="columnChange" :fields='fields' width="150"></ejs-dropdownlist>
</div>
<ejs-grid ref='grid' style="padding: 5px 5px" :dataSource="data" height='315px' :enableHover='false'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=100 :isFrozen="true"></e-column>
<e-column field='OrderDate' headerText='Order Date' width=100 format='yMd' textAlign='Right'></e-column>
<e-column field='EmployeeID' headerText='Employee ID' textAlign='Right' width=80></e-column>
<e-column field='ShipName' headerText='Ship Name' width=130></e-column>
<e-column field='ShipCity' headerText='Ship City' width=100></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width=100></e-column>
<e-column field='ShipRegion' headerText='Ship Region' width=80></e-column>
<e-column field='ShipPostalCode' headerText='Ship Postal Code' width=110></e-column>
<e-column field='Freight' headerText='Freight' width=80></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script setup>
import { provide, ref } from "vue";
import { GridComponent as EjsGrid, ColumnDirective as EColumn, ColumnsDirective as EColumns, Freeze } from "@syncfusion/ej2-vue-grids";
import { DropDownListComponent as EjsDropdownlist } from "@syncfusion/ej2-vue-dropdowns";
import { data } from "./datasource.js";
const grid = ref(null);
const fields = { text: 'text', value: 'value' };
const dropDownData = [
{ text: 'CustomerID', value: 'CustomerID' },
{ text: 'OrderID', value: 'OrderID' },
{ text: 'OrderDate', value: 'OrderDate' },
{ text: 'EmployeeID', value: 'EmployeeID' },
{ text: 'ShipName', value: 'ShipName' },
{ text: 'ShipCity', value: 'ShipCity' },
{ text: 'ShipCountry', value: 'ShipCountry' },
{ text: 'ShipRegion', value: 'ShipRegion' },
{ text: 'ShipPostalCode', value: 'ShipPostalCode' },
{ text: 'Freight', value: 'Freight' },
];
const columnChange = function(args) {
const selectedColumn = grid.value.ej2Instances.getColumnByField(args.value);
// Iterate through all columns and unfreeze any previously frozen columns
grid.value.ej2Instances.columns.forEach((column) => {
if (column.isFrozen) {
column.isFrozen = false;
}
});
// Freeze the newly selected column, if it exists
if (selectedColumn) {
selectedColumn.isFrozen = true;
}
// Refresh the columns
grid.value.ej2Instances.refreshColumns();
}
provide('grid', [Freeze]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-calendars/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/tailwind.css";
</style>
<template>
<div id="app">
<div style="display: inline-block;">
<label> Change the frozen column: </label>
<ejs-dropdownlist id='dropdownlist' :dataSource='dropDownData' index="0" :change="columnChange" :fields='fields' width="150"></ejs-dropdownlist>
</div>
<ejs-grid ref='grid' style="padding: 5px 5px" :dataSource="data" height='315px' :enableHover='false'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=100 :isFrozen="true"></e-column>
<e-column field='OrderDate' headerText='Order Date' width=100 format='yMd' textAlign='Right'></e-column>
<e-column field='EmployeeID' headerText='Employee ID' textAlign='Right' width=80></e-column>
<e-column field='ShipName' headerText='Ship Name' width=130></e-column>
<e-column field='ShipCity' headerText='Ship City' width=100></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width=100></e-column>
<e-column field='ShipRegion' headerText='Ship Region' width=80></e-column>
<e-column field='ShipPostalCode' headerText='Ship Postal Code' width=110></e-column>
<e-column field='Freight' headerText='Freight' width=80></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import { GridComponent, ColumnsDirective, ColumnDirective, Freeze } from "@syncfusion/ej2-vue-grids";
import { DropDownListComponent } from "@syncfusion/ej2-vue-dropdowns";
import { data } from "./datasource.js";
export default {
name: "App",
components: {
"ejs-dropdownlist":DropDownListComponent,
"ejs-grid":GridComponent,
"e-columns":ColumnsDirective,
"e-column":ColumnDirective
},
data() {
return {
data: data,
fields: { text: 'text', value: 'value' },
dropDownData: [
{ text: 'CustomerID', value: 'CustomerID' },
{ text: 'OrderID', value: 'OrderID' },
{ text: 'OrderDate', value: 'OrderDate' },
{ text: 'EmployeeID', value: 'EmployeeID' },
{ text: 'ShipName', value: 'ShipName' },
{ text: 'ShipCity', value: 'ShipCity' },
{ text: 'ShipCountry', value: 'ShipCountry' },
{ text: 'ShipRegion', value: 'ShipRegion' },
{ text: 'ShipPostalCode', value: 'ShipPostalCode' },
{ text: 'Freight', value: 'Freight' },
]
};
},
methods: {
columnChange: function(args) {
const grid = this.$refs.grid.$el.ej2_instances[0]
const selectedColumn = grid.getColumnByField(args.value);
// Iterate through all columns and unfreeze any previously frozen columns
grid.columns.forEach((column) => {
if (column.isFrozen) {
column.isFrozen = false;
}
});
// Freeze the newly selected column, if it exists
if (selectedColumn) {
selectedColumn.isFrozen = true;
}
// Refresh the columns
grid.refreshColumns();
}
},
provide: {
grid: [Freeze]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-calendars/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/tailwind.css";
</style>
Freeze direction
In the Syncfusion Vue Grid, the “freeze direction” feature serves to reposition frozen columns either to the left, right, or in a fixed position, while still allowing the remaining columns to be horizontally movable. This feature is designed to optimize user experience by ensuring that critical information remains visible even during horizontal scrolling. By default, when you set the frozenColumns
property of the grid or the isFrozen
property of individual columns, it results in freezing those columns on the left side of the grid. This helps in keeping important data readily accessible as you navigate through your dataset.
To achieve this, you can utilize the column.freeze property. This property is used to specify the freeze direction for individual columns. The grid will adjust the column positions based on the column.freeze
value.
The types of the column.freeze
directions:
-
Left: When you set the
column.freeze
property to Left, specific columns will be frozen on the left side of the grid. The remaining columns will be movable. -
Right: When you set the
column.freeze
property to Right, certain columns will be frozen on the right side of the grid, while the rest of the columns remain movable. -
Fixed: The Fixed direction locks a column at a fixed position within the grid. This ensures that the column is always visible during horizontal scroll.
In the following example, the ShipCountry column is frozen on the left side, the CustomerID column is frozen on the right side and the Freight column is frozen on the fixed of the content table. Additionally, you can modify the column.freeze
property to Left, Right and Fixed based on the selected column by utilizing the change event of the DropDownList
component.
<template>
<div id="app">
<div style="display: inline-block;">
<label> Change column: </label>
<ejs-dropdownlist ref='columnDropdown' id='columnDropdown' :dataSource='columnData' index="0" :fields='fields' width="150"></ejs-dropdownlist>
<label> Change freeze direction: </label>
<ejs-dropdownlist ref='directionDropdown' id='directionDropdown' :dataSource='directionData' index="0" :fields='fields' width="150"></ejs-dropdownlist>
</div>
<ejs-button ref='button' cssClass='e-outline' v-on:click="freezeDirectionFn">Update</ejs-button>
<ejs-grid ref='grid' style="padding: 5px 5px" :dataSource="data" height='315px' :enableHover='false'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='90' textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' width='90' format='C2' textAlign='Right' freeze='Fixed'></e-column>
<e-column field='CustomerID' headerText='Customer ID' width='100' freeze='Right'></e-column>
<e-column field='OrderDate' headerText='Order Date' width='100' format="yMd" textAlign='Right'></e-column>
<e-column field='ShipName' headerText='Ship Name' width='100'></e-column>
<e-column field='ShipAddress' headerText='Ship Address' width='120'></e-column>
<e-column field='ShipCity' headerText='Ship City' width='110'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='100' freeze='Left'></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script setup>
import { provide, ref } from "vue";
import { GridComponent as EjsGrid, ColumnDirective as EColumn, ColumnsDirective as EColumns, Freeze } from "@syncfusion/ej2-vue-grids";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
import { DropDownListComponent as EjsDropdownlist } from "@syncfusion/ej2-vue-dropdowns";
import { data } from "./datasource.js";
const grid = ref(null);
const columnDropdown = ref(null);
const directionDropdown = ref(null);
const fields = { text: 'name', value: 'id' };
const columnData = [
{ id: 'OrderID', name: 'Order ID' },
{ id: 'Freight', name: 'Freight' },
{ id: 'CustomerID', name: 'Customer ID' },
{ id: 'OrderDate', name: 'Order Date' },
{ id: 'ShipName', name: 'Ship Name' },
{ id: 'ShipAddress', name: 'Ship Address' },
{ id: 'ShipCity', name: 'Ship City' },
{ id: 'ShipCountry', name: 'Ship Country' },
];
const directionData = [
{ id: 'Left', name: 'Left' },
{ id: 'Right', name: 'Right' },
{ id: 'Fixed', name: 'Fixed' },
];
const freezeDirectionFn = function () {
grid.value.ej2Instances.getColumnByField(columnDropdown.value.$el.ej2_instances[0].value).freeze = directionDropdown.value.$el.ej2_instances[0].value
grid.value.ej2Instances.refreshColumns();
}
provide('grid', [Freeze]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-calendars/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/tailwind.css";
</style>
<template>
<div id="app">
<div style="display: inline-block;">
<label> Change column: </label>
<ejs-dropdownlist ref='columnDropdown' id='columnDropdown' :dataSource='columnData' index="0" :fields='fields' width="150"></ejs-dropdownlist>
<label> Change freeze direction: </label>
<ejs-dropdownlist ref='directionDropdown' id='directionDropdown' :dataSource='directionData' index="0" :fields='fields' width="150"></ejs-dropdownlist>
</div>
<ejs-button ref='button' cssClass='e-outline' v-on:click="freezeDirectionFn">Update</ejs-button>
<ejs-grid ref='grid' style="padding: 5px 5px" :dataSource="data" height='315px' :enableHover='false'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='90' textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' width='90' format='C2' textAlign='Right' freeze='Fixed'></e-column>
<e-column field='CustomerID' headerText='Customer ID' width='100' freeze='Right'></e-column>
<e-column field='OrderDate' headerText='Order Date' width='100' format="yMd" textAlign='Right'></e-column>
<e-column field='ShipName' headerText='Ship Name' width='100'></e-column>
<e-column field='ShipAddress' headerText='Ship Address' width='120'></e-column>
<e-column field='ShipCity' headerText='Ship City' width='110'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='100' freeze='Left'></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import { GridComponent, ColumnsDirective, ColumnDirective, Freeze } from "@syncfusion/ej2-vue-grids";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
import { DropDownListComponent } from "@syncfusion/ej2-vue-dropdowns";
import { data } from "./datasource.js";
export default {
name: "App",
components: {
"ejs-dropdownlist":DropDownListComponent,
"ejs-button":ButtonComponent,
"ejs-grid":GridComponent,
"e-columns":ColumnsDirective,
"e-column":ColumnDirective
},
data() {
return {
data: data,
fields: { text: 'name', value: 'id' },
columnData: [
{ id: 'OrderID', name: 'Order ID' },
{ id: 'Freight', name: 'Freight' },
{ id: 'CustomerID', name: 'Customer ID' },
{ id: 'OrderDate', name: 'Order Date' },
{ id: 'ShipName', name: 'Ship Name' },
{ id: 'ShipAddress', name: 'Ship Address' },
{ id: 'ShipCity', name: 'Ship City' },
{ id: 'ShipCountry', name: 'Ship Country' },
],
directionData: [
{ id: 'Left', name: 'Left' },
{ id: 'Right', name: 'Right' },
{ id: 'Fixed', name: 'Fixed' },
]
};
},
methods: {
freezeDirectionFn: function () {
const grid = this.$refs.grid.$el.ej2_instances[0]
grid.getColumnByField(this.$refs.columnDropdown.$el.ej2_instances[0].value).freeze = this.$refs.directionDropdown.$el.ej2_instances[0].value
grid.refreshColumns();
}
},
provide: {
grid: [Freeze]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-calendars/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/tailwind.css";
</style>
- Freeze Direction is not compatible with the isFrozen and frozenColumns properties.
Change default frozen line color
You can customize the frozen line borders of frozen columns in the Syncfusion Grid component by applying custom CSS styles to the specific frozen column. This allows you to change the border color of the left frozen columns, right frozen columns, and fixed frozen columns to match your application’s design and theme.
To change default frozen line color, use the following class name and apply the border color based on your requirement.
For left frozen columns:
.e-grid .e-leftfreeze.e-freezeleftborder {
border-right-color: rgb(198, 30, 204);
}
For right frozen columns:
.e-grid .e-rightfreeze.e-freezerightborder {
border-left-color: rgb(19, 228, 243);
}
For fixed frozen columns, you need to specify both left and right border as mentioned below
.e-grid .e-fixedfreeze.e-freezeleftborder{
border-left-color: rgb(9, 209, 9);
}
.e-grid .e-fixedfreeze.e-freezerightborder{
border-right-color: rgb(10, 224, 10);
}
The following example demonstrates how to change the default frozen line color using CSS.
<template>
<div id="app">
<ejs-grid ref='grid' :dataSource="data" height='315px' :enableHover='false'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=100 freeze='Left'></e-column>
<e-column field='OrderDate' headerText='Order Date' width=100 format='yMd' textAlign='Right'></e-column>
<e-column field='EmployeeID' headerText='Employee ID' textAlign='Right' width=80></e-column>
<e-column field='ShipName' headerText='Ship Name' width=130></e-column>
<e-column field='ShipAddress' headerText='Ship Address' width=140 freeze='Fixed'></e-column>
<e-column field='ShipCity' headerText='Ship City' width=100></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width=100 freeze='Right'></e-column>
<e-column field='ShipRegion' headerText='Ship Region' width=80></e-column>
<e-column field='ShipPostalCode' headerText='Ship Postal Code' width=110></e-column>
<e-column field='Freight' headerText='Freight' width=80></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script setup>
import { provide } from "vue";
import { GridComponent as EjsGrid, ColumnDirective as EColumn, ColumnsDirective as EColumns, Freeze} from "@syncfusion/ej2-vue-grids";
import { data } from './datasource.js';
provide('grid', [Freeze]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-calendars/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/tailwind.css";
.e-grid .e-fixedfreeze.e-freezeleftborder{
border-left-color: rgb(9, 209, 9) !important;
}
.e-grid .e-fixedfreeze.e-freezerightborder{
border-right-color: rgb(10, 224, 10) !important;
}
.e-grid .e-rightfreeze.e-freezerightborder {
border-left-color: rgb(19, 228, 243) !important;
}
.e-grid .e-leftfreeze.e-freezeleftborder {
border-right-color: rgb(198, 30, 204) !important;
}
</style>
<template>
<div id="app">
<ejs-grid ref='grid' :dataSource="data" height='315px' :enableHover='false'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=100 freeze='Left'></e-column>
<e-column field='OrderDate' headerText='Order Date' width=100 format='yMd' textAlign='Right'></e-column>
<e-column field='EmployeeID' headerText='Employee ID' textAlign='Right' width=80></e-column>
<e-column field='ShipName' headerText='Ship Name' width=130></e-column>
<e-column field='ShipAddress' headerText='Ship Address' width=140 freeze='Fixed'></e-column>
<e-column field='ShipCity' headerText='Ship City' width=100></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width=100 freeze='Right'></e-column>
<e-column field='ShipRegion' headerText='Ship Region' width=80></e-column>
<e-column field='ShipPostalCode' headerText='Ship Postal Code' width=110></e-column>
<e-column field='Freight' headerText='Freight' width=80></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import { GridComponent, ColumnsDirective, ColumnDirective, Freeze} from "@syncfusion/ej2-vue-grids";
import { data } from './datasource.js';
export default {
name: "App",
components: {
"ejs-grid":GridComponent,
"e-columns":ColumnsDirective,
"e-column":ColumnDirective
},
data() {
return {
data: data
};
},
provide: {
grid: [Freeze]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-calendars/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind.css";
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/tailwind.css";
.e-grid .e-fixedfreeze.e-freezeleftborder{
border-left-color: rgb(9, 209, 9) !important;
}
.e-grid .e-fixedfreeze.e-freezerightborder{
border-right-color: rgb(10, 224, 10) !important;
}
.e-grid .e-rightfreeze.e-freezerightborder {
border-left-color: rgb(19, 228, 243) !important;
}
.e-grid .e-leftfreeze.e-freezeleftborder {
border-right-color: rgb(198, 30, 204) !important;
}
</style>
Deprecated methods
Previous | Current | Explanation |
---|---|---|
getMovableRows() gridInstance.getMovableRows()[0].querySelectorAll(‘.e-unfreeze’) |
getRows() gridInstance.getRows()[0].querySelectorAll(‘.e-unfreeze’) |
The previous architecture used separate tables for left, right, and movable contents, returning only movable rows when calling the method, whereas the current architecture combines them into one table, returning all rows and introduces the e-unfreeze class for selecting movable rows |
getFrozenRightRows() gridInstance.getFrozenRightRows()[0].querySelectorAll(‘.e-rightfreeze’) |
getRows() gridInstance.getRows()[0].querySelectorAll(‘.e-rightfreeze’) |
In the previous architecture, it returned only the table rows from the right freeze table, but in the current architecture, all rows of the entire table are returned, introducing the e-rightfreeze class for selecting right freeze rows. |
getMovableRowByIndex() getFrozenRowByIndex() getFrozenRightRowByIndex()
|
getRowByIndex() gridInstance.getRowByIndex(1).querySelectorAll(‘.e-unfreeze’) |
In the previous architecture, separate methods were used to select rows from different table sections, while in the current architecture, the getMovableRowByIndex() , getFrozenRightRowByIndex() , and getFrozenRowByIndex() methods now return the same table row based on the given index. Additionally, class names for table cells (td’s) have been separated into e-leftfreeze , e-unfreeze , and e-rightfreeze , making it easier to customize cells within a row. |
getMovableCellFromIndex() getFrozenRightCellFromIndex()
|
getCellFromIndex() gridInstance.getCellFromIndex(1,1) |
In the previous approach, the getMovableCellFromIndex() method was used to choose a specific cell within the movable table, and the getFrozenRightCellFromIndex() method was utilized to target a particular cell within the right freeze table. However, in the current architecture, you have the flexibility to select a specific cell in either the movable or right freeze table by using both the getFrozenRightCellFromIndex() and getMovableCellFromIndex() methods. This new method simplifies the process of selecting and retrieving specific cells within these tables, offering more versatility and convenience. |
getMovableDataRows() getFrozenRightDataRows() getFrozenDataRows()
|
getDataRows() gridInstance.getDataRows()[0].querySelectorAll(‘.e-unfreeze’) |
In the previous approach, there were separate methods (getMovableDataRows() , getFrozenRightDataRows() , and getFrozenDataRows() ) for obtaining viewport data rows from the freeze, movable, and right tables individually. However, in the new approach, these methods have been enhanced to return the entire viewport data rows for all sections together, simplifying data retrieval. You can now extract specific cells within these rows using selectors such as e-leftfreeze for the left freeze, e-unfreeze for the movable, and e-rightfreeze for the right freeze tables, providing greater flexibility in working with the data. |
getMovableColumnHeaderByIndex() getFrozenRightColumnHeaderByIndex() getFrozenLeftColumnHeaderByIndex()
|
getColumnHeaderByIndex() gridInstance.getColumnHeaderByIndex(1) |
In the previous architecture, the methods selected movable, right freeze, and left freeze headers separately. However, in the new approach, when using the getMovableColumnHeaderByIndex() , getFrozenRightColumnHeaderByIndex() , and getFrozenLeftColumnHeaderByIndex() methods, you will still obtain the same results as in the previous architecture. |
When a validation message is displayed in the frozen part (Left, Right, Fixed) of the table, scrolling is prevented until the validation message is cleared.
Limitations
While freezing columns in the Syncfusion Vue Grid provides enhanced visibility and scrolling capabilities, there are certain limitations to consider. The following features are not supported when using frozen columns:
- Detail Template
- Hierarchy Grid
- Autofill