Cell Selection in ASP.NET MVC Tree Grid Component
21 Dec 20221 minute to read
Cell selection can be done through simple mouse down or arrow keys (up, down, left, and right).
The treegrid supports two types of cell selection mode that can be set by using the CellSelectionMode
property of SelectionSettings
. They are:
- Flow: The Flow value is set by default. The range of cells are selected between the start index and end index that includes in between cells of rows.
- Box: Range of cells are selected from the start and end column indexes that includes in between cells of rows within the range.
@(Html.EJS().TreeGrid("SelectionAPI").AllowPaging()
.DataSource((IEnumerable<object>)ViewBag.datasource)
.AllowSelection()
.Columns(col =>
{
col.Field("TaskId").HeaderText("Task ID").Width(110).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("TaskName").HeaderText("Task Name").Width(210).Add();
col.Field("StartDate").HeaderText("Start Date").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Width(210).Add();
col.Field("Duration").HeaderText("Duration").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width(190).Add();
})
.ChildMapping("Children").SelectionSettings(select => select.CellSelectionMode(Syncfusion.EJ2.Grids.CellSelectionMode.Flow)
.Mode(Syncfusion.EJ2.Grids.SelectionMode.Cell).Type(Syncfusion.EJ2.Grids.SelectionType.Multiple)).TreeColumnIndex(1).Render())
public IActionResult Index()
{
var tree = TreeData.GetDefaultData();
ViewBag.datasource = tree;
return View();
}
NOTE
Cell selection requires the
Mode
to be Cell or Both, and Type should be Multiple.
You can refer to ourASP.NET MVC Tree Grid
feature tour page for its groundbreaking feature representations. You can also explore ourASP.NET MVC Tree Grid example
to knows how to present and manipulate data.