We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Customizing the Grid Toolbar

Thread ID:

Created:

Updated:

Platform:

Replies:

117531 Nov 4,2014 03:46 PM UTC Nov 5,2014 01:19 PM UTC ASP.NET MVC 1
loading
Tags: Grid
Fabio Melendez
Asked On November 4, 2014 03:46 PM UTC

What is the best approach to customize the Grid Toolbar. For example I have users that will have permissions to Add rows to the grid and others that won't

I have already created the ToolbarSettings for the grid , but need to be able to make visible or enable/disable one of the buttons (ToolbarItems.Add)

My User Role is determined in the ViewBag, so for example

@if (ViewBag.LoggedUser.CanAdd)
{
        //Enable toolBarItems.Add button in grid
}

Mohammed Farook J [Syncfusion]
Replied On November 5, 2014 01:19 PM UTC

Hi Fabio,

Thanks for using Syncfusion products.

 

Based on your request , we have created a sample and the same can be downloaded from the following link:

 

Sample: customToolbar.zip

 

Please find the code snippet for custom button with enable and disable toolbar option in grid.

 

@(Html.EJ().Button("btn").ClientSideEvents(c => c.Click("enableToolBar")).Text("EnableToolBar"))

@(Html.EJ().Button("btn1").ClientSideEvents(c => c.Click("disableToolBar")).Text("DisableToolBar"))

@(Html.EJ().Grid<MvcApplication50.OrdersView>("FlatGrid")

        .Datasource((IEnumerable<object>)ViewBag.datasource)

       

         .AllowPaging()    /*Paging Enabled*/

        .Columns(col =>

        {

                . . .

       }))

<script type="text/javascript">

    function enableToolBar(args) {

 

        $("#FlatGrid").ejGrid("option", { toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, })

 

    }

 

    function disableToolBar(args) {

        $("#FlatGrid").ejGrid("option", { toolbarSettings: { showToolbar: false}})

           

    }

</script>

 

Please let us know if you have any queries.

 

Regards,

J.Mohammed Farook


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;