Results 1 to 5 of 5

Thread: [4.1.1] Ext.Editor revertInvalid causes unexpected behavior when set to false.

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    Sep 2010
    Posts
    100
    Vote Rating
    5
      0  

    Default [4.1.1] Ext.Editor revertInvalid causes unexpected behavior when set to false.

    4.1.1 Ext.Editor revertInvalid causes the grid to not display the right value after two clicks.


    REQUIRED INFORMATION
    Ext version tested:

    • Ext 4.1.*
    Description:
    • Ext.Editor revertInvalid causes the grid to not display the right value after two clicks.
    Test Case:
    Set revertInvalid to false and use the cell editing plugin.

    Steps to reproduce:
    Invalidate a cell.
    Click on a cell in the invalidated cell's column.
    Blur.
    Invalidated cell is populated with its old value.

    ?

    Code:
    Ext.require('*');
    
    Ext.onReady(function() {
        function formatDate(value) {
            return value ? Ext.Date.dateFormat(value, 'M d, Y') : '';
        }
    
    
        Ext.override(Ext.Editor, {
            revertInvalid: false
        });
    
        Ext.define('Plant', {
            extend: 'Ext.data.Model',
            fields: [{
                name: 'common',
                type: 'string'
            }, {
                name: 'botanical',
                type: 'string'
            }, {
                name: 'light'
            }, {
                name: 'price',
                type: 'float'
            }, {
                name: 'availDate',
                mapping: 'availability',
                type: 'date',
                dateFormat: 'm/d/Y'
            }, {
                name: 'indoor',
                type: 'bool'
            }]
        });
    
        var store = Ext.create('Ext.data.Store', {
            autoDestroy: true,
            model: 'Plant',
            proxy: {
                type: 'ajax',
                url: '../SDK/extjs/examples/grid/plants.xml',
                reader: {
                    type: 'xml',
                    record: 'plant'
                }
            },
            sorters: [{
                property: 'common',
                direction: 'ASC'
            }]
        });
    
        var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1
        });
    
        var grid = Ext.create('Ext.grid.Panel', {
            store: store,
            columns: [{
                id: 'common',
                header: 'Common Name',
                dataIndex: 'common',
                flex: 1,
                editor: {
                    allowBlank: false
                }
            }, {
                header: 'Light',
                dataIndex: 'light',
                width: 130,
                editor: new Ext.form.field.ComboBox({
                    typeAhead: true,
                    triggerAction: 'all',
                    selectOnTab: true,
                    store: [['Shade', 'Shade'], ['Mostly Shady', 'Mostly Shady'], ['Sun or Shade', 'Sun or Shade'], ['Mostly Sunny', 'Mostly Sunny'], ['Sunny', 'Sunny']],
                    lazyRender: true,
                    listClass: 'x-combo-list-small'
                })
            }, {
                header: 'Price',
                dataIndex: 'price',
                width: 70,
                align: 'right',
                renderer: 'usMoney',
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    minValue: 0,
                    maxValue: 100000
                }
            }, {
                header: 'Available',
                dataIndex: 'availDate',
                width: 95,
                renderer: formatDate,
                editor: {
                    xtype: 'datefield',
                    format: 'm/d/y',
                    minValue: '01/01/06',
                    disabledDays: [0, 6],
                    disabledDaysText: 'Plants are not available on the weekends'
                }
            }],
            selModel: {
                selType: 'cellmodel'
            },
            renderTo: document.body,
            width: 600,
            height: 300,
            plugins: [cellEditing]
        });
        store.load();
    });
    Last edited by evant; 5 Nov 2012 at 1:26 PM. Reason: Fix up test case.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      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 User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    1,017
    Vote Rating
    125
      0  

    Default

    A year has passed. Is it supposed to be fixed? It would be good.

    The same fix as for a similar issue in ExtJS 3 works.
    http://www.sencha.com/forum/showthread.php?271318

    Fix
    Code:
    Ext.Editor.override({
        completeEdit : function(remainVisible) {
            var me = this,
                field = me.field,
                value;
    
            if (!me.editing) {
                return;
            }
    
            // Assert combo values first
            if (field.assertValue) {
                field.assertValue();
            }
    
            value = me.getValue();
            if (!field.isValid()) {
                if (me.revertInvalid !== false) {
                    me.cancelEdit(remainVisible);
                    return;
                }
            }
    
            if (String(value) === String(me.startValue) && me.ignoreNoChange) {
                me.hideEdit(remainVisible);
                return;
            }
    
            if (me.fireEvent('beforecomplete', me, value, me.startValue) !== false) {
                // Grab the value again, may have changed in beforecomplete
                value = me.getValue();
                if (me.updateEl && me.boundEl) {
                    me.boundEl.update(value);
                }
                me.hideEdit(remainVisible);
                me.fireEvent('complete', me, value, me.startValue);
            }
        }
    });
    Object.NET
    Frameworks and Tools for .NET Developers
    --------------------------------------------------
    Ext.NET - Ext JS for ASP.NET - Examples | Twitter
    Bridge.NET - Write C#. Run JavaScript! - Live | Twitter
    --------------------------------------------------

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2010
    Posts
    100
    Vote Rating
    5
      1  

    Default

    Here is the override we have in our code. It is quite nasty to maintain and it looks like it can be fixed by moving the return statement to take account for revertInvalid.

    Code:
    Ext.define('Ext.overrides.Editor', {
        override: 'Ext.Editor',
    
    
        /**
         * @extBug
         * @version 4.1.0 - 4.2.2
         * Fixing problem of set value logic not getting run if revertInvalid is false.
         */
        completeEdit: function(remainVisible) {
            var me = this,
                field = me.field,
                value;
    
    
            if (!me.editing) {
                return;
            }
    
    
            // Assert combo values first
            if (field.assertValue) {
                field.assertValue();
            }
    
    
            value = me.getValue();
            if (!field.isValid()) {
                if (me.revertInvalid !== false) {
                    me.cancelEdit(remainVisible);
                    return;
                }
    
    
                //START EDIT
                //moved return statement into the revertInvalid if block
                //END EDIT
            }
    
    
            if (String(value) === String(me.startValue) && me.ignoreNoChange) {
                me.hideEdit(remainVisible);
                return;
            }
    
    
            if (me.fireEvent('beforecomplete', me, value, me.startValue) !== false) {
                // Grab the value again, may have changed in beforecomplete
                value = me.getValue();
                if (me.updateEl && me.boundEl) {
                    me.boundEl.update(value);
                }
                me.hideEdit(remainVisible);
                me.fireEvent('complete', me, value, me.startValue);
            }
        }
    });

  5. #5
    Sencha Premium Member
    Join Date
    Nov 2012
    Posts
    7
    Vote Rating
    0
      0  

    Default

    This is still an issue in 4.2.2 as well as 5.0.1. Is this going to be fixed?

Posting Permissions

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