Hala HB
Hala HB

Reputation: 13

telerik - add toolbar and command to an existing kendo UI grid

I have this grid

$("#LocationGrid").kendoGrid({
dataSource: locationDataSource,
editable: "inline",
columns: [  { field: "LocationID", hidden: "hidden" },
            { field: "LocationName", title: "Location Name" },
            { command: [{ name: "edit" }] }]
});

i want to add toolbar with create button to this grid if the user has permission

if(condition) //user has permission
{
 //add toolbar to grid
 toolbar: [{ name: "create", text: "Add New Location}],
}

and also add "Delete" button to command column if the user has permission

if(condition) //user has permission
{
 //add delete button to grid
 command: [{ name: "delete"}]
}

how i can perform this, please?

Upvotes: 1

Views: 1546

Answers (1)

Gopinath
Gopinath

Reputation: 266

We can use the setOptions() method of grid like below,

if(condition)
{
  var grid = $("#grid").data("kendoGrid");
  grid.setOptions({
    toolbar: [{name: "create", text: "Add New Location"}]
  });
}

Refer http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-setOptions

Upvotes: 1

Related Questions