rubyrain
20 Sep 2012, 9:17 AM
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.
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();
});
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.
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();
});