1 首先定义gridview id
viewConfig : { itemId: 'listsgridview', },
2 在Controller里面增加监听函数
"#listsgridview": { itemkeydown: this.onListsgridviewItemKeydown },
3 函数实现
onListsgridviewItemKeydown: function(dataview, record, item, index, e, eOpts) { var key = e.getKey(); var store = record.store; if(key>=e.A && key<=e.Z){ var initial = String.fromCharCode(key); var localIndex = index; do{ localIndex++; record = store.getAt(localIndex); }while(record && record.get('name').indexOf(initial.toLowerCase()) !== 0 && localIndex<=store.data.length-1); if(record && record.get('name').indexOf(initial.toLowerCase()) === 0 && localIndex<=store.data.length-1){ dataview.select(localIndex); } } return false; },
用户在表格里面按键后可以定位到具体的行(首字母为按键字母)