Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Button text in Kendo Ui Grid Popup Window

I've got a Kendo UI Grid that loads a popup when creating a new or editing an existing record.

I struggling to find a way to change the change the text of the Update button to "Save" when I'm creating a new record (it currently says "Update" - and its not correct).

I was able to change the title of the popup window, but my question is: how do I change the button text?

This is the code:

 $("#grid").kendoGrid({
            dataSource: dataSource,
            pageable: true,
            sortable: true,
            groupable: true,
            height: resizeGrid(),
            filterable: true,
            toolbar: ["create"],
            columns: [
                { field: "OfficeName", title: "Office Name" },
                { field: "SupportNo", title: "Phone No.", width: "100px" },
                { field: "SupportEmail", title: "Email Address", width: "130px" },
                { field: "SupportFax", title: "Fax No.", width: "100px" },
                { field: "SupportFtp", title: "Ftp Url", width: "150px" },
                { command: ["edit", "destroy"], title: "Actions", width: "160px" }],
            editable: "popup",
            edit: function (e) {
                var editWindow = e.container.data("kendoWindow");

                if (e.model.isNew()) {
                    e.container.data("kendoWindow").title('Add New Office');
                    $(".k-grid-update").text = "Save";
                }
                else {
                    e.container.data("kendoWindow").title('Edit Office');
                }
            }
        });
like image 949
EdsonF Avatar asked Jun 04 '13 21:06

EdsonF


2 Answers

You should define command as:

command: [
    {
        name: "edit",
        text: { 
            edit: "Edit",               // This is the localization for Edit button
            update: "Save",             // This is the localization for Update button
            cancel: "Cancel changes"    // This is the localization for Cancel button
        }
    },
    { 
        name: "destroy", 
        text: "Delete Office"           // This is the localization for Delete button
    }
]

In addition, if you also want to change the text Edit in the popup window, you should use:

editable  : {
    mode : "popup",
    window : {
        title: "Edit Office",           // Localization for Edit in the popup window
    }
}
like image 72
OnaBai Avatar answered Sep 19 '22 17:09

OnaBai


This will update the text in the button of the PopUp Editor:

if (e.model.isNew()) {
  $("a.k-grid-update")[0].innerHTML = "<span class='k-icon k-update'></span>Activate";
}
else {
  $("a.k-grid-update")[0].innerHTML = "<span class='k-icon k-update'></span>Save";
}
like image 28
Martin Leir Avatar answered Sep 16 '22 17:09

Martin Leir