-
20 Sep 2012 9:17 AM #1
Answered: Focus jump in RowEditing plugin in Ext.window
Answered: Focus jump in RowEditing plugin in Ext.window
Hi,
While I was working on something, I encountered a strange problem. I searched forums but couldn't find anything similar to this issue, so here it is. Ext version is 4.1.1. I don't think I had this problem with 4.0.7 but not 100% sure.
I have an editable grid with rowediting plugin, which is inside of Ext.Window.
I use numberfield as editor for 2 columns and have minValue, minLength, maxLength, enforceMaxLength set.
When I start editing a row, and if a field becomes valid from invalid, the focus is lost from the field (I think it is focusing window). This prevents me using 'Enter' key to update the row, or use 'Tab' key to navigate to other editor fields. When editable grid is inside a container that is not floating (that is, other than Ext.Window), it acts as normal.
To reproduce try this code. Once grid inside window shows, click top button to add a row, then start editing.
minLength and maxLength are set to 9. so as you start editing, you get red border, tooltip indicating the field is invalid. As you type 9th number, invalid marks are gone, but as well as the focus.
Not sure this is bug or something in my code. (I tried to make it simple. This is part of more complex app)
Thanks in advance.
Code:Ext.define('BarcodeRange', { extend: 'Ext.data.Model', fields: [ 'start', 'end', { name: 'count', type: 'int' } ] }); Ext.define('BarcodeRanges', { extend: 'Ext.data.Store', model: 'BarcodeRange' }); Ext.onReady(function() { var bGrid = Ext.create('widget.grid', { columns: [ { header: 'Start', dataIndex: 'start', flex: 1, soartable: false, editor: { xtype: 'numberfield', itemId: 'startBarcode', maxLength: 9, enforceMaxLength: true, minLength: 9, validateOnChange: false, tabIndex: 1, hideTrigger: true, minValue: 0, allowDecimals: false } }, { header: 'End', dataIndex: 'end', flex: 1, soartable: false, editor: { xtype: 'numberfield', itemId: 'endBarcode', maxLength: 9, enforceMaxLength: true, minLength: 9, validateOnChange: false, tabIndex: 1, hideTrigger: true, minValue: 0, allowDecimals: false } }, { header: 'Count', dataIndex: 'count', width: 45, soartable: false, align: 'right' }, { xtype : 'actioncolumn', header : 'Cancel', width : 50, align : 'center', soartable: false, items : [ { icon: '/imgs/delete_icon.png', iconCls: 'action-shipment-edit', handler: function(grid, rix, cix) { grid.getStore().removeAt(rix); } } ] } ], dockedItems : [ { xtype: 'toolbar', dock: 'top', items: [ { xtype: 'button', text: 'Add Barcode Sequence', icon: '/imgs/add.png', handler: function(btn, e) { var newBarcodeRange = Ext.create('BarcodeRange'); btn.up('grid').getStore().add(newBarcodeRange); btn.up('grid').getPlugin('rowEditor').startEdit(newBarcodeRange, 0); } } ] }, { xtype: 'toolbar', dock: 'bottom', items: [ '->', { xtype: 'numberfield', itemId: 'partialBarcode', fieldLabel: 'Partial (Optional)', width: 200, allowDecimals: false, hideTrigger: true, maxLength: 9, enforceMaxLength: true, minLength: 9, minValue: 0, listeners: { errorchange: function(comp, error, eopts) { var saveButton = comp.up('window').down('button[action=Save]'); if (error === "") { saveButton.enable(); } else { saveButton.disable(); } } } } ] } ], plugins: [ { ptype: 'rowediting', pluginId: 'rowEditor', clicksToEdit: 2 } ] }); var win = Ext.create('widget.window', { title : 'Barcodes Ranges', width : 300, height : 300, closeAction : 'hide', closable : false, modal : true, layout : 'fit', buttonAlign : 'right', buttons : [ { xtype: 'button', action: 'Save', text: 'Save', handler: function() { /*me.saveBarcodes*/ } } ], items : [ bGrid] }); win.show(); });
-
Best Answer Posted by mitchellsimoens
This was a bug that should be fixed in a later release. Plus, perf is much greater in 4.1
-
24 Sep 2012 6:34 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,682
- Vote Rating
- 435
- Answers
- 3111
This was a bug that should be fixed in a later release. Plus, perf is much greater in 4.1
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
24 Sep 2012 7:20 AM #3
Thanks Mitchell, but is there any temporary fix for this? I'm really pushing for 4.1 upgrade at work (yeah, performance is a lot better in 4.1), but users will be really annoyed if I do nothing about this.
-
28 Sep 2012 10:07 AM #4
For the record, I had to use focus(false, 20) to work around this problem.
Also I had another focus problem if I add a record and used startEdit in window's show event. (it would focus window instead of the editor. I could see that editor field was focused but then the focus jumps to the window. I think window uses some kind of deferred focus) I also worked around this using Ext.deferCode:{ header: 'Start', dataIndex: 'start', flex: 1, soartable: false, editor: { xtype: 'numberfield', itemId: 'startBarcode', maxLength: 9, enforceMaxLength: true, minLength: 9, vtype: '', minLengthText:'Required length is 9 digits',maxLengthText:'Required length is 9 digits', hideTrigger: true, keyNavEnabled: false, mouseWheelEnabled: false, minValue: 0, allowDecimals: false, listeners: { errorchange: function(comp, error, eopts) { comp.focus(false, 50); } } } }, { header: 'End', dataIndex: 'end', flex: 1, soartable: false, editor: { xtype: 'numberfield', itemId: 'endBarcode', maxLength: 9, enforceMaxLength: true, minLength: 9, vtype: '', hideTrigger: true, minLengthText:'Required length is 9 digits',maxLengthText:'Required length is 9 digits', keyNavEnabled: false, mouseWheelEnabled: false, minValue: 0, allowDecimals: false, listeners: { errorchange: function(comp, error, eopts) { comp.focus(false, 50); } } } }
-
16 Oct 2012 12:51 PM #5
Hi,
I am also experiencing this issue and am running on version 4.1.1. Could you please provide the ticket number so I may track when it is complete?
Thanks.


Reply With Quote