【问题标题】:Telerik MVC Grid insert button textTelerik MVC Grid 插入按钮文本
【发布时间】:2012-05-17 08:38:49
【问题描述】:

如何更改 Telerik MVC 网格上插入命令按钮的文本。

我正在使用具有 2 个子级别的 Master-Detail,并且我想单独个性化每个级别。我现在知道的唯一方法是从 jQuery 更改所有插入按钮。

我认为解决方案应该是具有自定义命令和模拟插入功能的操作。

Chrissav 的解决方案:

.ToolBar(commands => commands.Insert().HtmlAttributes( new { id = "addLvl1" }))
.ClientEvents(e => e.OnLoad("changeText")

功能

 function changeText() {
         $('[id=addLvl1]').text('Insert Level 1');
         $('[id=addLvl2]').text('Insert Level 2');
         $("[id=addLvl3]").text('Insert Level 3');
     }

【问题讨论】:

    标签: asp.net-mvc telerik telerik-grid telerik-mvc


    【解决方案1】:

    这篇文章解释了它只能通过本地化来完成: http://www.telerik.com/community/forums/aspnet-mvc/grid/grid-insert-button-text.aspx

    我也刚刚使用 Jquery 完成了这项工作。

    在网格中:

    .ToolBar(commands => commands.Insert().HtmlAttributes( new { id = "myID" }))
    .ClientEvents(e => e
                .OnLoad("changeText")
    

    jq:

    function changeText() {
            $('#myID').text('change the text here');
        }
    

    你提到尝试自定义命令,所以你可以尝试这样的事情

    .ToolBar(commands => commands.Custom() .Text("Insert Text") .Action("Action", "Controller")
    

    【讨论】:

    • 非常感谢克里斯萨夫。解决方案 1 和 3 并不能真正解决我的问题,但第二个很有效。我的网格是 Master-Detail,因此更改本地化会更改所有“插入”按钮。另外,我使用的是 Ajax,所以我不能调用 .Action("Action", "Controller") 因为它会打开一个新视图。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多