telerik-向现有剑道UI网格添加工具栏和命令

telerik-向现有剑道UI网格添加工具栏和命令,telerik,kendo-grid,Telerik,Kendo Grid,我有这个网格 $("#LocationGrid").kendoGrid({ dataSource: locationDataSource, editable: "inline", columns: [ { field: "LocationID", hidden: "hidden" }, { field: "LocationName", title: "Location Name" }, { command: [{ name: "edit" }]

我有这个网格

$("#LocationGrid").kendoGrid({
dataSource: locationDataSource,
editable: "inline",
columns: [  { field: "LocationID", hidden: "hidden" },
            { field: "LocationName", title: "Location Name" },
            { command: [{ name: "edit" }] }]
});
如果用户有权限,我想将带有“创建”按钮的工具栏添加到此网格

if(condition) //user has permission
{
 //add toolbar to grid
 toolbar: [{ name: "create", text: "Add New Location}],
}
if(condition) //user has permission
{
 //add delete button to grid
 command: [{ name: "delete"}]
}
如果用户有权限,还可以在命令列中添加“删除”按钮

if(condition) //user has permission
{
 //add toolbar to grid
 toolbar: [{ name: "create", text: "Add New Location}],
}
if(condition) //user has permission
{
 //add delete button to grid
 command: [{ name: "delete"}]
}
请问我该怎么做

我们可以使用网格的“setOptions()”方法,如下所示

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

参见

Hi。你找到解决这个问题的办法了吗?