剑道网格工具栏的多个重载



我正在尝试配置一个剑道网格工具栏,以便在网格中具有剑道"创建"功能,并且内部还具有自定义按钮。这是我到目前为止所拥有的:

   @(Html.Kendo().Grid<VIEWMODELHERE>()
            .Name("UserProfileGrid")
            .Resizable(c => c.Columns(true))
            .Selectable()
            .Filterable()
            .Groupable()
            .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("UserCreateTemplate"))
            .ToolBar(x => x.Create(), x.Template(@<text>
                    @(Html.Kendo().Button()
                    .Name("ButtonAddUser")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("downloads")
                    .Content("Add User")
                    .Events(e => e.Click("createUser")))
                    @(Html.Kendo().Button()
                    .Name("ButtonEditUser")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("settings")
                    .Content("Edit User")
                    .Events(e => e.Click("Edituser")))
                    @(Html.Kendo().Button()
                    .Name("ButtonRefreshPage")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("Refresh Page")
                    .Events(e => e.Click("RefreshPage")))
                    @(Html.Kendo().Button()
                    .Name("ButtonDeleteUser")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("Delete a user")
                    .Events(e => e.Click("DeleteUser")))
                    @(Html.Kendo().Button()
                    .Name("ButtonAbout")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("About")
                    .Events(e => e.Click("aboutButtonClick")))
            </text>)));

问题是我似乎无法使用 lambda 函数正确创建按钮,因为它没有正确读取创建函数。

如您所知,您有一个语法问题。 由于您在工具栏命令(x.Create 和 x.Template)中使用了多个命令,因此您需要通过将主体包装在"{}"中将其转换为块。 在 x.Create() 之后去一个 ";" 来结束这一行。

.ToolBar(x =>
{
    x.Create();
    x.Template(@<text>
        @(Html.Kendo().Button()
    .Name("ButtonAddUser")
    .HtmlAttributes(new { type = "k-button" })
    .Icon("downloads")
    .Content("Add User")
    .Events(e => e.Click("createUser")))
    </text>);
})

普拉尚特你是对的!对于将来遇到此问题的用户,您可以轻松执行此操作:

<a class='k-button k-grid-add' href='#'>Add new User</a>

所以我现在有:

  toolbar.Template(@<text>

                    <a class='k-button k-grid-add' href='#'>Add new User</a>
                    @(Html.Kendo().Button()
                    .Name("ButtonEditUser")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("settings")
                    .Content("Edit User")
                    .Events(x => x.Click("Edituser")))
                        @(Html.Kendo().Button()
                    .Name("ButtonRefreshPage")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("Refresh Page")
                    .Events(x => x.Click("RefreshPage")))
                        @(Html.Kendo().Button()
                    .Name("ButtonDeleteUser")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("Delete a user")
                    .Events(x => x.Click("DeleteUser")))
                        @(Html.Kendo().Button()
                    .Name("ButtonAbout")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("About")
                    .Events(x => x.Click("aboutButtonClick")))
                    </text>);})

也许不漂亮,雷蛇和html的混合...但它适用于我们的敏捷环境。

最新更新