Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS 4 > Row Editor Grid > How to Change "Update" Button Text

Tags:

extjs

extjs4

Is there any way to change the text of "Update" button in ExtJS-4 Row Editor Grid ?

like image 986
Ahsan Avatar asked Oct 13 '11 07:10

Ahsan


3 Answers

Good question, I had a look through the source code and whilst there is nothing inside the RowEditing plugin, in the class it extends 'RowEditor.js' there is the following:

Ext.define('Ext.grid.RowEditor', {
    extend: 'Ext.form.Panel',
    requires: [
        'Ext.tip.ToolTip',
        'Ext.util.HashMap',
        'Ext.util.KeyNav'
    ],

    saveBtnText  : 'Update',
    cancelBtnText: 'Cancel',
    ...
});

So I'd assume you'd just need to override the 'saveBtnText' in your instance of 'Ext.grid.plugin.RowEditing' as it calls the parent constructor with callParent(arguments) in the RowEditing class

like image 156
dougajmcdonald Avatar answered Nov 06 '22 05:11

dougajmcdonald


Not that easy and not without hacking in undocumented areas. The problem is, that the Ext.grid.plugin.RowEditing directly instantiates the Ext.grid.RowEditor without allowing you to pass in configuration options. So in general you have to override the initEditor() method in the plugin and instantiate your own row editor:

// ...
plugins: [{
    ptype: 'rowediting',
    clicksToEdit: 2,
    initEditor: function() {
        var me = this,
            grid = me.grid,
            view = me.view,
            headerCt = grid.headerCt;

        return Ext.create('Ext.grid.RowEditor', {
            autoCancel: me.autoCancel,
            errorSummary: me.errorSummary,
            fields: headerCt.getGridColumns(),
            hidden: true,

            // keep a reference..
            editingPlugin: me,
            renderTo: view.el,
            saveBtnText: 'This is my save button text', // <<---
            cancelBtnText: 'This is my cancel button text' // <<---
        });
    },
}],
// ...
like image 4
Stefan Gehrig Avatar answered Nov 06 '22 06:11

Stefan Gehrig


For ExtJS 4

Ext.grid.RowEditor.prototype.cancelBtnText = "This is cancel";
Ext.grid.RowEditor.prototype.saveBtnText = "This is update";
like image 3
UUHHIVS Avatar answered Nov 06 '22 07:11

UUHHIVS