EXTJS 3 Ext.Paging Toolbar()ショートカットキーアプリケーション
5002 ワード
/**
*
* @example " " "Page Up"
* @example " " "Page Down"
* @example "Home"
* @example "End"
*
* @example !
* <p>1. store load
* <p> :
* <p>store.on('load',function(){
* <p> if(store.getCount()>0){
* <p> grid.getSelectionModel().selectFirstRow();//
* <p> grid.getView().focusRow(0);//
* <p> }
* <p>});
* <p>2. grid keydown
* <p> :
* <p>grid.on('keydown',function(e){
* <p> e.stopEvent();
* <p> var thisPagingToolbar = Ext.getCmp('PagingToolbar ID');
* <p> PagingToolbar_KeyEvent(thisPagingToolbar,e);
* <p>});
* @param {} thisPagingToolbar
* @param {} e
*/
function PagingToolbar_KeyEvent(thisPagingToolbar,e){
if((e.getKey()==Ext.EventObject.LEFT) || (e.getKey()==Ext.EventObject.PAGE_UP) ){
if(thisPagingToolbar.readPage()!=1)
thisPagingToolbar.movePrevious();
}
if((e.getKey()==Ext.EventObject.RIGHT) || (e.getKey()==Ext.EventObject.PAGE_DOWN)){
if(thisPagingToolbar.readPage()!=thisPagingToolbar.getPageData().pages)
thisPagingToolbar.moveNext();
}
if(e.getKey()==Ext.EventObject.HOME){
if(thisPagingToolbar.readPage()!=1)
thisPagingToolbar.moveFirst();
}
if(e.getKey()==Ext.EventObject.END){
if(thisPagingToolbar.readPage()!=thisPagingToolbar.getPageData().pages)
thisPagingToolbar.moveLast();
}
}
//
var customerTypesDataStore = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({
url:'./customerType/list.tc'
}),
reader:new Ext.data.JsonReader(
{root:"Records",totalProperty:"RecordCount"},
[
{name : 'CustomerTypeCode',type : 'int'},
{name : 'CustomerTypeName',type : 'string'},
{name : 'ReCounts',type : 'int'}
]
)
});
customerTypesDataStore.on('beforeload', function() {
customerTypesDataStore.removeAll();
this.baseParams = {
searchText:customerTypesGridPanel.SearchField.getValue()
};
});
customerTypesDataStore.on('load',function(){
if(customerTypesDataStore.getCount()>0){
customerTypesGridPanel.getSelectionModel().selectFirstRow();
customerTypesGridPanel.getView().focusRow(0);
}
});
var customerTypes_grid = Ext.grid;
var customerTypes_grid_PageSize = 20;
function customerTypesDataStore_load(){
customerTypesDataStore.load({params:{start:0,limit:customerTypes_grid_PageSize}});
}
var customerTypesGridPanel = new customerTypes_grid.GridPanel({
store:customerTypesDataStore,//
loadMask : {
msg : ' ...'
},
cm: new customerTypes_grid.ColumnModel([
new customerTypes_grid.RowNumberer(),
{header:' ', dataIndex:'CustomerTypeCode',width:80},
{header:' ', dataIndex:'CustomerTypeName'},
{header:' ', dataIndex:'ReCounts'}
]),
viewConfig: {
forceFit:true
},
columnLines: true,
region:'center',
iconCls:'icon-grid',
tbar: [
new Ext.form.TextField({
ref:'../SearchField',
emptyText:' / ',
width:500
,selectOnFocus:true
,enableKeyEvents:true
,listeners:{
specialkey:function(field,e){
if (e.getKey()==Ext.EventObject.ENTER){
e.stopEvent();
customerTypesDataStore_load();
}
}
}
}),{
text:' ',
tooltip:' ',
iconCls:'search',
handler:function(){
customerTypesDataStore_load();
}
}
],
bbar: new Ext.PagingToolbar({
id:'customerTypesGridPanel_paging',// ID
pageSize: customerTypes_grid_PageSize,
store: customerTypesDataStore,
displayInfo: true,
displayMsg: ' {0}-{1} / {2} ',
emptyMsg: " "
}),
sm: new customerTypes_grid.RowSelectionModel({
singleSelect:true,
}),
listeners:{
'keydown':function(e){
e.stopEvent();
PagingToolbar_KeyEvent(Ext.getCmp('customerTypesGridPanel_paging'),e);
// ID
}
}
});