Articles in this section
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:

  1. Top – New row is added at the top of all rows.
  2. Bottom - New row is added at the bottom of all rows.
  3. AboveSelectedRow - New row is added above the selected row.
  4. 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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment