Reputation: 2750
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');
}
Upvotes: 0
Views: 2857
Reputation: 66
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")
Upvotes: 3