grid 表头 鼠标事件

grid.addListener("cellclick", cellclick);
function cellclick(grid, rowIndex, columnIndex, e) {
    var record = grid.getStore().getAt(rowIndex);   //Get the Record
    var fieldName = grid.getColumnModel().getDataIndex(columnIndex); //Get field name
    var data = record.get(fieldName);
    Ext.MessageBox.alert("show","当前选中的数据是"+data);
}



headermousedown ( Grid this, Number columnIndex, Ext.EventObject e ) 
//当头部被单击之前触发。
  headerclick ( Grid this, Number columnIndex, Ext.EventObject e ) 
头部(header)被单击时触发


4.如何做Grid中做出快捷菜单效果:
grid.addListener("rowcontextmenu", rightClickFn);//右键菜单代码关键部分
var rightClick = new Ext.menu.Menu({
    id:"rightClickCont", //在HTML文件中必须有个rightClickCont的DIV元素
    items: [
        {
            id: "rMenu1",
            handler: rMenu1Fn,//点击后触发的事件
            text: "右键菜单1"
        },
        {
            //id: "rMenu2",
            //handler: rMenu2Fn,
            text: "右键菜单2"
        }
    ]
});
function rightClickFn(grid,rowindex,e){
    e.preventDefault();
    rightClick.showAt(e.getXY());
}
function rMenu1Fn(){
   Ext.MessageBox.alert("right","rightClick");
}

你可能感兴趣的:(html,ext)