用ext开发一个gridPanel 却遇到了无法触发事件的问题  看下面代码  /* 分类grid */
var sortGrid = new Ext.grid.GridPanel({
    border:false,
    ds:sortds,
    AllowPaging:true,
    cm: new Ext.grid.ColumnModel([
        new Ext.grid.RowNumberer(),
        {header: "类型ID", width: 80, sortable: true,locked:true, dataIndex: 'sortId'},
        {header: "类型名称", width: 200, sortable: true,locked:false, dataIndex: 'sortName'},
        {header: "父类型ID", width: 80, sortable: true, locked:false,dataIndex: 'parentSortId'},
        {header: "所属图书数", width: 80, sortable: true,locked:false, dataIndex: 'sortNumber'}
        
    ]),    viewConfig: {
        forceFit:true
    },
    bbar : new Ext.PagingToolbar({  
        id: 'sortPagebar',  
        pageSize:15,  
        store:sortds,  
        displayInfo:true,
         }),    tbar:[{
        text:'增加图书分类',
        tooltip:'Add a new sort',
        iconCls:'add',
        handler:function(){ alert(1);}
      
        },{
        text:'删除图书分类',
        tooltip:'Remove a sort,the sort can not be empty',
        iconCls:'remove',
        handler:function(){
       
        }
    }],
    
});
MyDesktop.SortWindow = Ext.extend(Ext.app.Module, {
    id:'sort-win',
    init : function(){
        this.launcher = {
            text: '分类管理',
            iconCls:'icon-sort-grid',
            handler : this.createWindow,
            scope: this
        }
    },    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('sort-win');
        if(!win){
            win = desktop.createWindow({
                id: 'sort-win',
                title:'分类管理',
                width:600,
                height:423,
                iconCls: 'icon-sort-grid',
                shim:false,
                animCollapse:false,
                constrainHeader:true,                layout: 'fit',
                items:[
                   sortGrid
                 ]
            });
        }
        sortds.load({params:{start:0, limit:15}});
        win.show();
    },
    
    
});发现增加图书分类等的tbar都能正常显示 但是handler里的事件点了却无法触发 求问

解决方案 »

  1.   

     handler:function(){ 
          alert('come here')
            } 
    这样不行吗?
      

  2.   

    回licip 就是不行 让我狂郁闷 我写着呢   tbar:[{ 
            text:'增加图书分类', 
            tooltip:'Add a new sort', 
            iconCls:'add', 
            handler:function(){ alert(1);} 就是死都不运行 alert(1)
      

  3.   

    listeners:{'click': function(){alert(1);}}
    这样试试
      

  4.   

    用你的代码试验了下,发现很多js错误,将错误排除后,可以正常alert(1),建议你先查看下你的所有代码,事件关联应该是没问题的。
    错误例如:
    tbar:[{ 
            text:'增加图书分类', 
            tooltip:'Add a new sort', 
            iconCls:'add', 
            handler:function(){ alert(1);} 
          
            },{ 
            text:'删除图书分类', 
            tooltip:'Remove a sort,the sort can not be empty', 
            iconCls:'remove', 
            handler:function(){ 
          
            } 
        }], 
    这句最后不应该有逗号
      

  5.   

    我这里没发上其他网站,qq也不行,没发看你的js文件。desktop之前也用这个开发过,没有你出现的问题。建议你可以在重新建一个窗体,窗体上只有个tbar,然后触发事件。若还不行,则只能看看你的ext或ext的desktop源码是否被修改过了。