PDA

View Full Version : How do I trap the enter key in the paging toolbar search field?



daniel_82
12 Aug 2009, 9:34 PM
I already traped the other key enter evant on paging toolbar. :)

Another two questions:
1, how can I want trap the enter key in the paging toolbar search field (Page xx of xxx) as well.
2, how can I get the customer entered page number in this page field.

Thanks in advance.~o)

13 Aug 2009, 9:29 AM
Look at the KeyMap API and the textField api, specifically , "keys"

Animal
13 Aug 2009, 11:13 AM
When was enableKeyEvents implemented in Ext.form.Field? Is it in the OP's version?

13 Aug 2009, 11:15 AM
Dont' know. Even if it wasn't enabling key handlers on dom nodes is basic javascript

daniel_82
13 Aug 2009, 3:55 PM
I tried but still doesn't work. I just want to get the enter key event on the pagingtoolbar.
Here is the code. What is wrong?


var pagingBar = new Ext.PagingToolbar({
pageSize: 15,
store: storeMain,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
});
// map one key by key code
var map = new Ext.KeyMap(pagingBar.getEl(), {
key: 13, // or Ext.EventObject.ENTER
fn: function() { alert("Return was pressed"); }
});
Ext.PagingToolbar.prototype.onClick = function(which) {
var _code = CmoCode.getRawValue();
var _Name = CmoName.getRawValue();
var _supplier = CmoSupplier.getValue();
if (CmoSupplier.getRawValue() == "")
{ _supplier = "0"; }
var _department = CmoDepartment.getValue();
if (CmoDepartment.getRawValue() == "")
{ _department = "0"; }
var _category = CmoCategory.getValue();
if (CmoCategory.getRawValue() == "")
{ _category = "0"; }
var _season = CmoSeason.getValue();
if (CmoSeason.getRawValue() == "")
{ _season = "0"; }
var _Active = '0';
if (Ext.getCmp("chk").getValue()) {
_Active = '1';
}
switch (which) {
case "first":
storeMain.reload({
params: { start: 0, limit: this.pageSize, strCode: _code, strName: _Name, strSeason: _season, strDepartment: _department, strCategory: _category, strSupplier: _supplier, strActive: _Active }
});
break;
case "prev":
storeMain.reload({
params: { start: Math.max(0, this.cursor - this.pageSize), limit: this.pageSize, strCode: _code, strName: _Name, strSeason: _season, strDepartment: _department, strCategory: _category, strSupplier: _supplier, strActive: _Active }
});
break;
case "next":
storeMain.reload({
params: { start: this.cursor + this.pageSize, limit: this.pageSize, strCode: _code, strName: _Name, strSeason: _season, strDepartment: _department, strCategory: _category, strSupplier: _supplier, strActive: _Active }
});
break;
case "last":
var total = storeMain.getTotalCount();
var extra = total % this.pageSize;
var lastStart = extra ? (total - extra) : total - this.pageSize;
storeMain.reload({
params: { start: lastStart, limit: this.pageSize, strCode: _code, strName: _Name, strSeason: _season, strDepartment: _department, strCategory: _category, strSupplier: _supplier, strActive: _Active }
});
break;
case "refresh":
storeMain.reload({
params: { start: this.cursor, limit: this.pageSize, strCode: _code, strName: _Name, strSeason: _season, strDepartment: _department, strCategory: _category, strSupplier: _supplier, strActive: _Active }
});
break;
}
};

Animal
13 Aug 2009, 10:55 PM
Check your level of the docs to see if enableKeyEvents is available to you.