问题描述
varfiledata={rows:args[1].file}varjsonstore=newExt.data.JsonStore({root:'rows',data:filedata,fields:[{name:'name',mapping:'name'},{name:'filemask',mapping:'filemask'},{name:'file_required',mapping:'file_required'}],listeners:{load:loadCallBack},autoLoad:true});functionloadCallBack(jsonstore,records,options){}varfm=Ext.form;varcsm=newExt.grid.CheckboxSelectionModel();varcm=newExt.grid.ColumnModel({defaults:{sortable:true},columns:[newExt.grid.RowNumberer({header:'#'}),{id:'name',header:'文件/目录',dataIndex:'name',width:220,editor:newfm.TextField({allowBlank:false,enableKeyEvents:true,keys:[{key:Ext.EventObject.F2,fn:function(){alert("");},scope:this}]})},{header:'通配符',dataIndex:'filemask',id:'filemask',width:130,editor:newfm.TextField({allowBlank:true})},{header:'要求',dataIndex:'file_required',id:'file_required',width:70,editor:newfm.ComboBox({editable:false,typeAhead:true,triggerAction:'all',transform:'yesorno',lazyRender:true,listClass:'x-combo-list-small'})},csm]});filegrid=newExt.grid.EditorGridPanel({store:jsonstore,cm:cm,renderTo:'editor-grid-1',//width:565,height:300,autoExpandColumn:'name',frame:true,clicksToEdit:1,sm:csm,tbar:['->',{xtype:'button',style:'padding:5555',text:'添加',handler:function(){varf=document.getElementById("fileORfolder").value;if(f==null||f==""){return;}else{varfilename=newString(document.getElementById("fileORfolder").value);varindex=filename.lastIndexOf(".");if(index==-1){alert("文件名不合法!!");return;}varpostfix=filename.substr(index+1);postfix=postfix.toLocaleLowerCase();if("xls"==postfix){alert("请选择文本类型的文件!!");return;}}varPlant=filegrid.getStore().recordType;varp=newPlant({name:f,filemask:document.getElementById('filemask_f').value});filegrid.stopEditing();varcount=jsonstore.getCount();jsonstore.insert(count,p);filegrid.startEditing(0,0);//varobj=document.getElementById("fileORfolder");//obj.outerHTML=obj.outerHTML;//document.getElementById("fileORfolder").value='';document.getElementById("fileORfolder").value='';document.getElementById("filemask_f").value='';}},{xtype:'button',style:'padding:5555',text:'清空',id:'clearAll',name:'butn',handler:function(){filegrid.stopEditing();jsonstore.removeAll();filegrid.startEditing(0,0);}},{xtype:'button',text:'删除选定',id:'deleteS',name:'butn',style:'padding:5555',handler:function(){filegrid.stopEditing();filegrid.getSelectionModel().each(function(rec){jsonstore.remove(rec);});filegrid.startEditing(0,0);}}]});//---------------------文件结束--------------------红色部分的注册的按键为什么不能用啊急求解答
解决方案
解决方案二:
也很迷惑,调试看过,根本就没有keyCode,估计是被拦截然后做了处理的原因;而且估计你用混淆了keys和specialkey,keys面板类才有,specialkeyfield系列可用;这种情况连keydown都没有能捕获到含有KeyCode的事件;