【问题标题】:Dynamically adding buttons to toolbar in Telerik MVC grid在 Telerik MVC 网格中向工具栏动态添加按钮
【发布时间】:2013-05-28 13:37:38
【问题描述】:

有没有办法以编程方式将多个项目添加到Telerik MVC Grid 的工具栏?

我通常会手动添加这样的项目,但是我想将一组项目添加到工具栏,并想知道是否有办法实现这一点?

.ToolBar(commands =>
{
   commands.Custom().HtmlAttributes(new { id = "btn-addproduct" }).Text("Add Product").HtmlAttributes(new { onclick = "addQuotationLine(" + Model.Id + ");return false;" });
 })

【问题讨论】:

    标签: razor telerik telerik-grid telerik-mvc


    【解决方案1】:

    配置器的参数是一个动作,所以你应该可以把任何有效的c#放在那里。这对我有用:

    .ToolBar(commands =>
    {
        for (int i = 0; i < 3; i++)
        {
            commands.Custom().Text("hello" + i);
        }
    })
    

    只需更改循环以遍历您的项目集合并相应地配置每个命令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多