Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET MVC > Grid > Grid insert button text

Not answered Grid insert button text

Feed from this thread
  • Mark Shortt avatar

    Posted on May 23, 2011 (permalink)

    Hi

    Can you tell me how to change the text of the insert button on the grid? I have tried using the Custom Command  method but that calls the method outside of the grid, instead of entering the new record within the grid

    Thanks

    Mark

    Reply

  • Atanas Korchev Atanas Korchev admin's avatar

    Posted on May 23, 2011 (permalink)

    Hi Mark Shortt,

     The only way to customize the Insert button text is by tweaking the grid localization.

    Kind regards,
    Atanas Korchev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Mark Shortt avatar

    Posted on May 23, 2011 (permalink)

    ok, thanks

    Reply

  • Joe avatar

    Posted on Jun 23, 2011 (permalink)

    Is there any way to customize the text for a grid on a specific page without changing it site-wide?

    Reply

  • Dimo Dimo admin's avatar

    Posted on Jun 24, 2011 (permalink)

    Hi Joe,

    You can use a Grid localization file on a specific page by setting Culture and UICulture only on that page.

    http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-localization.html

    This approach is actually used in our online demos where the localization capabilities of the components are demonstrated on specific pages only.

    Best wishes,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Joe avatar

    Posted on Jun 24, 2011 (permalink)

    Worked, thanks.

    Reply

  • Aaron avatar

    Posted on Jul 25, 2011 (permalink)

    Personally, I wouldn't use the UICulture hack; this could have unintended side-effects and is extremely cumbersome if you're doing a lot of customization.

    A faster way on single-language sites is to use a single line of jQuery:

    $("#Widgets .t-grid-add").first().text("Add new widget");

    You can even use this for master-detail grids, if the detail insert should have a different title (which is impossible to do by playing with culture settings alone). Example markup:

    @(Html.Telerik().Grid<Widget>()
        .Name("Widgets")
        ...
        .DetailView(v => v.ClientTemplate(
            Html.Telerik().Grid<Part>()
                .Name("WidgetParts_<#=Id#>")
                ...
                .ToolBar(b => b.Insert())
                .ClientEvents(e => e.OnLoad("partsGrid_OnLoad"))
                .ToHtmlString())))

    and the corresponding script:

    function partsGrid_OnLoad(e) {
        $(this).find(".t-grid-add").first().text("Add part");
    }

    Very easy.  And if you really need i18n then you can insert a code nugget into the text() parameter which looks up a localization string.

    Reply

  • Posted on Jul 28, 2011 (permalink)

    Great solution. One thing I would add, in case you're using GridButtonType.ImageAndText:

    $("#Widgets .t-grid-add").first().text("Add new widget").prepend("<span class='t-icon t-add'>");

    Otherwise, you'll lose the icon altogether.


    Reply

  • Robert avatar

    Posted on Apr 19, 2012 (permalink)

    Nevermind.

    Reply

  • Posted on May 14, 2012 (permalink)

    Mark, your answer is the best from what I can tell, but you need to change it from 

    $("#Widgets .t-grid-add").first().text("Add new widget").prepend("<span class='t-icon t-add'>");

     to

    $("#Widgets .t-grid-add").first().text("Add new widget").prepend("<span class='t-icon t-add' />");

    Notice the closing '/' at the end of the span tag.

    Reply

  • Posted on May 14, 2012 (permalink)

    Thanks, Matthew. Good catch.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET MVC > Grid > Grid insert button text
Related resources for "Grid insert button text"

ASP.NET MVC Grid Features  |  Documentation  |  Demos  |  Telerik TV ]