【问题标题】:telerik - add toolbar and command to an existing kendo UI gridtelerik - 将工具栏和命令添加到现有的剑道 UI 网格
【发布时间】:2015-09-23 14:24:59
【问题描述】:

我有这个网格

$("#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"}]
}

请问我该怎么做?

【问题讨论】:

  • 嗨。你找到解决办法了吗?

标签: telerik kendo-grid


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-27
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多