PDA

View Full Version : Textfield special key event bug



AkeB0N0
3 Sep 2013, 10:42 PM
I have textfield component as follows :


xtype: 'textfield',
id: 'articleNo',
flex: 1,
tabIndex: 1,
fieldLabel: 'ART?KEL NO',
fieldStyle: 'text-align: right; font-size: 12pt',
margins: '0 5 0 0',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() === e.ENTER || e.TAB) {
articles.load({
params: {'article': field.getValue(), 'type': 'article'},
callback: function () {
Ext.getCmp('articleDesc').setValue(articles.data.items[0].data['ART_DESC']);
}
});
}
},
focus: function (e) {
e.setValue('');
Ext.getCmp('articleDesc').setValue("");
articles.loadData([], false);
}
}

Data Model :

Ext.define('Article', {
extend: 'Ext.data.Model',
fields: [
{name: 'ARTICLE_ID', type: 'int'},
{name: 'SUBSYS_ART_NR', type: 'int'},
{name: 'ART_DESC', type: 'string'},
{name: 'SORTEN_TEXT', type: 'auto'},
{name: 'VAR', type: 'int'},
{name: 'GEBI', type: 'int'},
{name: 'DNR_ID', type: 'int'},
{name: 'STATUS', type: 'int'}
]
});

Json Store :

var articles = new Ext.data.JsonStore({
model: 'Article',
proxy: {
type: 'ajax',
url: '<?php echo base_url() ?>dashboard/create',
reader: {
type: 'json',
root: 'articleList',
idProperty: 'ARTICLE_ID'
}
}
});

What I want to do, when an user press the ENTER or TAB keys, query the database with filled article no. There is no problem which is working properly.

But, when we delete article no one by one with BACKSPACE, ExtJS automatically query the database with new value each BACKSPACE. It shouldn't be normal behaviour.

Is this bug or am I doing something wrong?

ettavolt
4 Sep 2013, 1:05 AM
>> (e.getKey() === e.ENTER || e.TAB )
If key is ENTER or we know value for TAB key... :)

AkeB0N0
4 Sep 2013, 3:50 AM
Pehh, as a matter of fact computer less clever from us :))

Thanks @ettavolt