Hybrid View

    You found a bug! We've classified it as EXTJS-7703 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium Member
    Join Date
    Sep 2010
    Posts
    98
    Vote Rating
    5
    plleeuwm is on a distinguished road

      0  

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

    [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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,563
    Vote Rating
    814
    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
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    974
    Vote Rating
    108
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      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);
            }
        }
    });
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2010
    Posts
    98
    Vote Rating
    5
    plleeuwm is on a distinguished road

      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);
            }
        }
    });
    Check out my small framework https://github.com/pllee/luc . I would love to get some feedback on it let me know what you think about it in a pm.

Thread Participants: 2