Results 1 to 9 of 9

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

    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
    89
      2  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Vote Rating
    1271
      0  

    Default

    Thanks for the report
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    316
    Vote Rating
    59
      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
    89
      0  

    Default

    Awesome, glad it was helpful!

  5. #5
    Sencha User
    Join Date
    Oct 2012
    Location
    France
    Posts
    9
    Vote Rating
    7
      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
    312
    Vote Rating
    4
      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
      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
      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
      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);

Posting Permissions

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