Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Change Text Buttons in Ext.grid.plugin.RowEditing

  1. #11
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,560

    Default

    Quote Originally Posted by Farish View Post
    how can I change the text of the buttons after the creation of the rowediting plugin? e.g. I would like to have "Add" when a user adds a new record and "Update" when the user clicks an existing record to edit it.
    I'm affraid it is deeper in the plugin code, not as simple as overriding some property.

    I solved that issue changing "Update" for "Save".

    Regards.
    UI: Sencha Architect / ExtJS 4 - 6
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: WildFly / Weblogic
    Databases: Oracle
    / MySQL / DB2 / Firebird

    If you like my answer please vote!

  2. #12
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,101

    Default

    I am using the following now to change the button text after creation of the RowEditing plugin (which I have named rowEditing):

    Code:
    rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
        id:'rowEditing',
        clicksToEdit: 2
    });
    rowEditing.editor.saveBtnText = "Add";
    console.log(rowEditing);
    when the rowEditing plugin is printed in the console, I can see that the saveBtnText in the editor has indeed been changed but still it appears as Update when the grid is being edited. The strange thing is that sometimes it is changed to Add!

  3. #13
    Sencha User
    Join Date
    Mar 2011
    Location
    Arvada, CO
    Posts
    404

    Default

    I was having this problem, so I decided to create an override. I wish there was an easier way of getting the update button, through an actual getter, rather than having to use the #update itemId, but it works for now...

    Code:
    Ext.define('My.Namespace.RowEditingPluginOverride', {
      override: 'Ext.grid.plugin.RowEditing',
    
      /**
       * @method
       * Getter: creating a method for getting the Update button... this may break
       * in Ext 5, so make sure we check this
       * @return {Ext.button.Button} floatingUpdateButton
       */
      getUpdateButton: function() {
        var floatingUpdateButton = this.floatingUpdateButton;
        if (!floatingUpdateButton) {
          var editor = this.getEditor();
          if (editor) {
            var floatingButtons = editor.getFloatingButtons();
            if (floatingButtons) {
              floatingUpdateButton = this.floatingUpdateButton = floatingButtons.down('#update');
            }
          }
        }
        return floatingUpdateButton;
      },
    
      /**
       * @method
       * Setter: creating a method for setting the Update button's text... this may
       * break in Ext 5, so make sure we check this
       * @param {string} text
       */
      setUpdateButtonText: function(text) {
        var updateButton = this.getUpdateButton();
        if (updateButton) {
          updateButton.setText(text);
        }
      }
    });

  4. #14
    Sencha User
    Join Date
    Mar 2014
    Location
    Istanbul
    Posts
    1

    Default Locale override

    Another option is to override Ext.grid.RowEditor in locale file. Similar to apply function.

    Ext.define("Ext.locale.tr.grid.RowEditor", {
    override: "Ext.grid.RowEditor",
    saveBtnText: "Gncelle",
    cancelBtnText: "?ptal Et",
    errorsText: "Hatalar",
    dirtyText: "De?i?ikli?inizi onaylamal? ya da iptal etmelisiniz."
    });

    This is sample for Turkish language.

  5. #15
    Sencha Premium User
    Join Date
    Mar 2012
    Location
    germany
    Posts
    28

    Default a look on source code

    look at this source code method:

    initEditorConfig: function(){
    var me = this,
    grid = me.grid,
    view = me.view,
    headerCt = grid.headerCt,
    btns = ['saveBtnText', 'cancelBtnText', 'errorsText', 'dirtyText'],
    b,
    bLen = btns.length,
    cfg = {
    autoCancel: me.autoCancel,
    errorSummary: me.errorSummary,
    fields: headerCt.getGridColumns(),
    hidden: true,
    view: view,
    // keep a reference..
    editingPlugin: me
    },
    item;


    for (b = 0; b < bLen; b++) {
    item = btns[b];


    if (Ext.isDefined(me[item])) {
    cfg[item] = me[item];
    }
    }
    return cfg;
    }

    this method defines the config on init and look at this loop:

    for (b = 0; b < bLen; b++) {
    item = btns[b];


    if (Ext.isDefined(me[item])) {
    cfg[item] = me[item];
    }
    }


    on this loop done on btn Array it' searched in cfg Object if one of the btn Array strings exists.

    the only thing to do is to add manually a new property on instance. Just add the new property 'saveBtnText' to the editing plugin and give it a string value. Then on init of editor, this method will search such propertyname in cfg and the loop will do the rest!!!

  6. #16
    Sencha Premium Member erick.rosales@copamex.com's Avatar
    Join Date
    Jan 2016
    Location
    Mxico
    Posts
    2

    Default Lang ES

    Quote Originally Posted by ssamayoa View Post
    FWIW, this is part of my "ext-ux-lang-es.js" file:

    Code:
    Ext.onReady(function() {
        // No ux pero no est� en ext-lang-es.js
        if (Ext.grid.RowEditor) {
            Ext.apply(Ext.grid.RowEditor.prototype, {
                saveBtnText : "Guardar",
                cancelBtnText : "Cancelar",
                errorsText : "Errores",
                dirtyText : "Debe guardar o cancelar sus cambios"
            });
        }
    Hi ssamayoa, could you provide a URL to Download your locale JS file? (Puedes compartir tu Archivo)?

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •