Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-9957 in a recent build.
  1. #1
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    86
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      2  

    Default 4.2.1 Ext.grid.RowEditor onFieldChanged() No Longer Called

    4.2.1 Ext.grid.RowEditor onFieldChanged() No Longer Called


    When using Ext.grid.RowEditor in 4.2.1, changes in field values no longer update the enabled/disabled state of the "Update" button, nor the visibility of the error summary.

    Here's a fiddle that demonstrates the issue:

    http://jsfiddle.net/existdissolve/ACGNt/

    Steps to reproduce:
    • Add a record
    • "Car" is required
    • Even after entering a value for Car, "Update" button remains disabled and error summary is still visible.
    • Form, however, is submittable via Enter
    In looking at the source, it appears the main reason for this error is a change in initComponent().

    In 4.2.0, the following appears:

    Code:
    if (me.fields) {
        me.setField(me.fields, true);
        delete me.fields;
    }
    The setField() method, among other things, adds a change listener to the editor field which inevitably calls onFieldChange(), which handles updating the button, error summary, etc.

    In 4.2.1, however, the same section in initComponent() is:

    Code:
    if (me.fields) {
        me.addFieldsForColumn(me.fields, true);
        me.insertColumnEditor(me.fields);
        delete me.fields;
    }
    In looking briefly at these two alternative methods, I didn't see anywhere where they set listeners up on the editor field, which would explain why onFieldChange() never gets called.

    In fact, while onFieldChange() is still in the source of 4.2.1, I don't see anywhere that it is actually used.

    EDIT: If anyone needs a quick and dirty workaround, I found that simply overriding addFieldsForColumn() and adding the original mon() for the field seems to work. Not tested in many scenarios, but for my purposes it's a sufficient patch.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Touch Premium Member
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    311
    Vote Rating
    52
    droessner is a jewel in the rough droessner is a jewel in the rough droessner is a jewel in the rough

      0  

    Default


    Thanks for sharing your workaround. Seems to be sufficient for our cases as well.

  4. #4
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    86
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    Awesome, glad it was helpful!

  5. #5
    Sencha User
    Join Date
    Oct 2012
    Location
    France
    Posts
    4
    Vote Rating
    6
    eternoendless is on a distinguished road

      6  

    Default


    I don't want to sound bitchy, but seriously Sencha, do you even test things before releasing them?
    I've spent countless hours overriding broken things in 4.0.7, now that I upgraded to 4.2.1 there's new things that won't work properly. While I know bug-free code doesn't exist, it would be great if we could have a community-oriented hotfix repository, so that every time we bump into a bug we could simply search it into the database and find (or propose) the fix code, ready to copy and paste -- no more browsing in the forum.

    Anyway, here's the complete override, props to existdissolve:
    Code:
    Ext.override(Ext.grid.RowEditor,{
    
      addFieldsForColumn: function(column, initial) {
        var me = this,
            i,
            length, field;
    
    
        if (Ext.isArray(column)) {
            for (i = 0, length = column.length; i < length; i++) {
                me.addFieldsForColumn(column[i], initial);
            }
            return;
        }
    
    
        if (column.getEditor) {
    
    
          field = column.getEditor(null, {
              xtype: 'displayfield',
              getModelData: function() {
                  return null;
              }
          });
          if (column.align === 'right') {
              field.fieldStyle = 'text-align:right';
          }
    
    
          if (column.xtype === 'actioncolumn') {
              field.fieldCls += ' ' + Ext.baseCSSPrefix + 'form-action-col-field';
          }
    
    
          if (me.isVisible() && me.context) {
              if (field.is('displayfield')) {
                  me.renderColumnData(field, me.context.record, column);
              } else {
                  field.suspendEvents();
                  field.setValue(me.context.record.get(column.dataIndex));
                  field.resumeEvents();
              }
          }
          if (column.hidden) {
              me.onColumnHide(column);
          } else if (column.rendered && !initial) {
              me.onColumnShow(column);
          }
          
          // -- start edit
          me.mon(field, 'change', me.onFieldChange, me);
          // -- end edit
        }
      }
    });

  6. #6
    Ext JS Premium Member
    Join Date
    Nov 2008
    Posts
    293
    Vote Rating
    3
    wki01 is on a distinguished road

      0  

    Default


    Please make this optional feature.
    I prefer to have always on the save button.
    Now to get this now I have to do an override.

    Hello

  7. #7
    Sencha User
    Join Date
    Feb 2013
    Posts
    2
    Vote Rating
    0
    jctoledo is on a distinguished road

      0  

    Default


    How can I use this override with Sencha Architect? This bug affects massively to my project...

  8. #8
    Sencha User
    Join Date
    Feb 2013
    Posts
    2
    Vote Rating
    0
    jctoledo is on a distinguished road

      0  

    Default


    Done, we can put the override in the Launch function and it works... I don't know if this is the best way, but it works

  9. #9
    Sencha User
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    4
    Vote Rating
    1
    alba231 is on a distinguished road

      1  

    Default


    If grid's column has a config hidden:true than another bug at addManagedListener method (item is undefined). My workaround is:
    Code:
    if (!column.hidden) 
        me.mon(field, 'change', me.onFieldChange, me);