Frozen rows and columns

21 Dec 20224 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.

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.

@Html.EJS().TreeGrid("DefaultFunctionalities").DataSource((IEnumerable<object>)ViewBag.datasource).AllowSelection(false).Columns(col =>
    {
        col.Field("TaskId").HeaderText("Task ID").Width(100).TextAlign(TextAlign.Right).Add();
        col.Field("TaskName").HeaderText("Task Name").Width(230).Add();
        col.Field("StartDate").HeaderText("Start Date").Width(150).TextAlign(TextAlign.Right).Format("yMd").Add();
        col.Field("EndDate").HeaderText("End Date").Width(150).TextAlign(TextAlign.Right).Format("yMd").Add();
        col.Field("Duration").HeaderText("Duration").Width(120).TextAlign(TextAlign.Right).Add();
        col.Field("Progress").HeaderText("Progress").Width(120).TextAlign(TextAlign.Right).Add();
        col.Field("Priority").HeaderText("Priority").Width(120).Add();
        col.Field("Approved").HeaderText("Approved").TextAlign(TextAlign.Left).Type("boolean").Width(110).Add();
    }).Height(410).ChildMapping("Children").TreeColumnIndex(1).FrozenColumns(2).FrozenRows(3).Render()
public IActionResult FrozenColumn()
        {
            ViewBag.datasource = TreeData.GetDefaultData();
            return View();
        }

Freeze particular columns

To freeze particular column in the tree grid, the IsFrozen property can be used.

In this demo, the columns with field name TaskName and StartDate is frozen using the IsFrozen property.

@Html.EJS().TreeGrid("DefaultFunctionalities").DataSource((IEnumerable<object>)ViewBag.datasource).AllowSelection(false).Columns(col =>
    {
        col.Field("TaskId").HeaderText("Task ID").Width(100).TextAlign(TextAlign.Right).Add();
        col.Field("TaskName").HeaderText("Task Name").Width(230).IsFrozen(true).Add();
        col.Field("StartDate").HeaderText("Start Date").Width(150).IsFrozen(true).TextAlign(TextAlign.Right).Format("yMd").Add();
        col.Field("EndDate").HeaderText("End Date").Width(150).TextAlign(TextAlign.Right).Format("yMd").Add();
        col.Field("Duration").HeaderText("Duration").Width(120).TextAlign(TextAlign.Right).Add();
        col.Field("Progress").HeaderText("Progress").Width(120).TextAlign(TextAlign.Right).Add();
        col.Field("Priority").HeaderText("Priority").Width(120).Add();
        col.Field("Approved").HeaderText("Approved").TextAlign(TextAlign.Left).Type("boolean").Width(110).Add();
    }).Height(410).ChildMapping("Children").Render()
public IActionResult FrozenColumn()
        {
            ViewBag.datasource = TreeData.GetDefaultData();
            return View();
        }

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.

@Html.EJS().TreeGrid("DefaultFunctionalities").DataSource((IEnumerable<object>)ViewBag.datasource).AllowSelection(false).Columns(col =>
    {
        col.Field("TaskId").HeaderText("Task ID").Width(100).TextAlign(TextAlign.Right).Add();
        col.Field("TaskName").HeaderText("Task Name").Width(230).Freeze(Syncfusion.EJ2.Grids.FreezeDirection.Left).Add();
        col.Field("StartDate").HeaderText("Start Date").Width(150).TextAlign(TextAlign.Right).Format("yMd").Add();
        col.Field("EndDate").HeaderText("End Date").Width(150).TextAlign(TextAlign.Right).Format("yMd").Add();
        col.Field("Duration").HeaderText("Duration").Width(120).TextAlign(TextAlign.Right).Add();
        col.Field("Progress").HeaderText("Progress").Width(120).TextAlign(TextAlign.Right).Add();
        col.Field("Priority").HeaderText("Priority").Width(120).Freeze(Syncfusion.EJ2.Grids.FreezeDirection.Right).Add();
        col.Field("Approved").HeaderText("Approved").TextAlign(TextAlign.Left).Type("boolean").Width(110).Add();
    }).Height(410).TreeColumnIndex(1).ChildMapping("Children").Render()
public IActionResult FrozenColumn()
        {
            ViewBag.datasource = TreeData.GetDefaultData();
            return View();
        }

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.

NOTE

You can refer to our ASP.NET MVC Tree Grid feature tour page for its groundbreaking feature representations. You can also explore our ASP.NET MVC Tree Grid example to knows how to present and manipulate data.