0

How can the text be changed for the insert command button on a Telerik MVC Grid.

I am using Master-Detail with 2 sub-levels and I want to personalize each level individually. The only way I know now is to change all the insert buttons from jQuery.

I am thinking that the solution should be something with custom commands and an action that emulates the insert functionality.

Solution from Chrissav:

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

Function

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

1 Answer 1

3

This post explains it can only be done from localization: http://www.telerik.com/community/forums/aspnet-mvc/grid/grid-insert-button-text.aspx

I've also just done this using Jquery.

In the grid:

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

jq:

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

You mention trying custom commands so you can try something like this

.ToolBar(commands => commands.Custom() .Text("Insert Text") .Action("Action", "Controller")
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot Chrissav. Solutions 1 and 3 don't really work for my problem, but the second was bang on. My grid is Master-Detail so changing the localization would change it for all the Insert buttons. Also, I'm using Ajax so I can't call the .Action("Action", "Controller") because it would open a new view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.