Category / Section
How to specify the default position for rows added using Toolbar and context menu actions in the TreeGrid?
1 min read
In TreeGrid, you can add new rows either by using Toolbar or by Context Menu. You can set the position by using the RowPosition property for a newly added row. Following are the values for the RowPosition property:
- Top – New row is added at the top of all rows.
- Bottom - New row is added at the bottom of all rows.
- AboveSelectedRow - New row is added above the selected row.
- BelowSelectedRow - New row is added below the selected row.
Refer to the following code example.
MVC
<body> @(Html.EJ().TreeGrid("Tree") //... .EditSettings(edit => { edit.AllowEditing(true); edit.AllowAdding(true); edit.AllowDeleting(true); edit.EditMode(TreeGridEditMode.CellEditing); edit.RowPosition(TreeGridRowPosition.AboveSelectedRow); }) .Datasource((System.Collections.IEnumerable)ViewBag.datasource) ) @(Html.EJ().ScriptManager()) </body>
Sample Link:
You can find the demo sample in the following link, Sample