Articles in this section
Category / Section

How to move the custom tool items in front position of ASP.NET Core Grid toolbar list?

7 mins read

In ASP.NET Core Grid, items added under the custom toolbar items will displayed after the default toolbar items. This is the default behavior. This can be rearranged and move the custom tools prior to the default toolbar items in the dataBound event of the Grid which has been discussed in this KB.


<div id="Grid"></div>



<script type="text/javascript">
    $(function () {
            dataSource: window.gridData,
            allowPaging: true,
            pageSettings: { pageSize: 8 },
            groupSettings: {
                groupedColumns: ["EmployeeID"]
            allowGrouping: true,
            editSettings: { allowAdding: true, allowEditing: true, allowDeleting: true },
            toolbarSettings: { showToolbar: true,
                toolbarItems: ["add","edit","delete","update","cancel"],
                customToolbarItems: ["Expand", "Collapse", { templateID: "#Refresh" }]
            dataBound: "databound",
            //do custom action needed for
            //required custom tools
            //in toolbarClick event
            toolbarClick: "onToolBarClick",
            columns: [
                          { field: "OrderID", headerText: "Order ID", textAlign: ej.TextAlign.Right },
                          { field: "CustomerID", headerText: "Customer ID" },
                          { field: "EmployeeID", headerText: "Employee ID", textAlign: ej.TextAlign.Right },
                          { field: "Freight", headerText: "Freight", textAlign: ej.TextAlign.Right, format: "{0:C}" },
                          { field: "ShipCity", headerText: "Ship City" }



    .ToolbarSettings(toolbar =>
            toolbar.ShowToolbar().ToolbarItems(items =>
            .CustomToolbarItems(new List<object>() {  
            "Expand", "Collapse",  
            new Syncfusion.JavaScript.Models.CustomToolbarItem() { 
                TemplateID = "#Refresh" 
    .ClientSideEvents(e => {
        //rearrange the tools
        //do custom action needed for
        //required custom tools
        //in toolbarClick event
    .Columns(col =>
        col.Field("OrderID").HeaderText("Order ID").TextAlign(TextAlign.Right).Add();
        col.Field("CustomerID").HeaderText("Customer ID").Add();
        col.Field("ShipCity").HeaderText("Ship City").Add();



namespace MvcApplication66.Controllers
    public class HomeController : Controller
        public ActionResult Index()
            ViewBag.dataSource = OrderRepository.GetAllRecords();
            return View();



    <ej:Grid ID="Grid" runat="server" AllowPaging="true" AllowGrouping="true">
        <GroupSettings GroupedColumns="EmployeeID">
        <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>
        <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel">
                <ej:CustomToolbarItem Text="Expand" />
                <ej:CustomToolbarItem Text="Collapse" />
                <ej:CustomToolbarItem TemplateID="#Refresh" />
            <ej:Column Field="OrderID" HeaderText="Order ID" TextAlign="Right" />
            <ej:Column Field="CustomerID" HeaderText="Customer ID" />
            <ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Right" />
            <ej:Column Field="Freight" Format ="{0:C}" TextAlign="Right"/>
            <ej:Column Field="ShipCity" HeaderText="Ship City" />
        <ClientSideEvents ToolbarClick="onToolBarClick" DataBound="databound" />


        protected void Page_Load(object sender, EventArgs e)
            this.Grid.DataSource = order;


.Net Core

<ej-grid id="Grid" allow-paging="true" allow-grouping="true" toolbar-click="onToolBarClick" databound="databound" datasource="ViewBag.datasource">
    <e-toolbar-settings show-toolbar="true" toolbar-items=@(new List<string>() { "excelExport" })>
            <e-custom-toolbar-item text="Expand"></e-custom-toolbar-item>
            <e-custom-toolbar-item text="Collapse"></e-custom-toolbar-item>
            <e-custom-toolbar-item template-id="#Refresh"></e-custom-toolbar-item>
    <e-group-settings grouped-columns=@(new List<string>(){ "EmployeeID" })></e-group-settings>
    <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true"></e-edit-settings>
        <e-column field="OrderID" header-text="Order ID" text-align="Right"></e-column>
        <e-column field="EmployeeID" header-text="Employee ID" text-align="Right"></e-column>
        <e-column field="CustomerID" header-text="Customer ID"></e-column>
        <e-column field="Freight" text-align="Right" format="{0:C}"></e-column>
        <e-column field="ShipCity" header-text="Ship City"></e-column>


namespace core1.Controllers
    public partial class GridController : Controller
        public static List<Orders> order = new List<Orders>();
        public ActionResult GridFeatures()
            ViewBag.dataSource = order;
            return View();


Template and CSS:

<script id="Refresh" type="text/x-jsrender">
    <a class="e-toolbaricons e-icon refresh" />


<style type="text/css" class="cssStyles">
    .Expand:before {
        content: "\e627";
    .Collapse:before {
        content: "\e625";
    .refresh:before {
        content: "\e677";


Grid toolbar separated the default items and custom items under two different ul elements. In the databound event, collect all the elements from second ul element (or custom item list). Prepend the required items to the first ul or to the default items.

<script type="text/javascript">
    function databound(args) {
        // custom items
        var liElem = this.element.find(".e-gridtoolbar ul:eq('1') li");
        //default items
        var firstUl = this.element.find(".e-gridtoolbar ul:eq(0)");
        for (var l = 0 ; l < 2; l++) {
            //moving only two icons to front
            //leaving the last icon



<ej-grid id="Grid" #grid [allowPaging]="true" [editSettings]="edit" (dataBound)="databound($event)" [toolbarSettings]="toolbarsettings" >
        <e-column field="OrderID" headerText="Order ID" textAlign="right" ></e-column>
        <e-column field="CustomerID" headerText="Customer ID"></e-column>
        <e-column field="EmployeeID" headerText="Employee Name" textAlign="right"></e-column>
        <e-column field="Freight" format="{0:C}" textAlign="right"></e-column>
        <e-column field="ShipCity" headerText="Ship City"></e-column>



import { Component, OnInit, Input, ElementRef, ViewChild } from '@angular/core';
import { EJComponents } from "ej-angular2/src/ej/core";
    selector: 'ej-app',
    templateUrl: 'src/grid/grid.component.html',
export class GridComponent {
    constructor() {
        this.toolbarsettings = {
            showToolbar: true,
            toolbarItems: ["add", "edit", "delete", "update", "cancel"],
            customToolbarItems: [ "Expand", "Collapse",
                { templateID: "<a  class='e-toolbaricons e-icon refresh' />" }
        this.edit = {
            allowEditing: true,
            allowAdding: true,
            allowDeleting: true
        this.datasrc = data;
    public datasrc: any;
    public toolbarsettings: any;
    public edit: any;
    @ViewChild('grid') Grid: EJComponents<any, any>;//
    databound(e) {
        setTimeout($.proxy(function (args) {
            // custom items
            var liElem = this.Grid.widget.element.find(".e-gridtoolbar ul:eq('1') li");
            //default items
            var firstUl = this.Grid.widget.element.find(".e-gridtoolbar ul:eq(0)");
            for (var l = 0; l < 2; l++) {
                //moving only two icons to front
                //leaving the last icon
        },this), 0)


ASP.NET Core Grid

Figure 1. Grid with rearranged toolbar items.


I hope you enjoyed learning about how to move the custom tool items in front position of ASP.NET Core Grid toolbar list.

You can refer to our  ASP.NET Core Grid feature tour page to know about its other groundbreaking feature representations. You can also explore our  ASP.NET Core Grid examples to understand how to present and manipulate data.

For current customers, you can check out our ASP.NET Core Controls from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our ASP.NET Core DataGrid and other ASP.NET Core controls.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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