http://blog.sina.com.cn/s/blog_60f09f9d0100e4cu.html
1. grid 添加行点击事件
grid.addListener('cellclick',function(grid, rowIndex,columnIndex,e){
if(columnIndex == 1){
var record = grid.getStore().getAt(rowIndex).data;
AddWin(record,1);
}
});
2. grid 添加右键功能
grid.on('rowcontextmenu',function(grid,index,e){
var data = grid.getStore().getAt(index).data;
var firstLegal = {
text: '一one',
handler : function(){
}
};
var firstIllegal = {
text: '一two',
handler : function(){
}
};
var secondLegal = {
text: '二one',
handler : function(){
}
};
var secondIllegal = {
text: '二two',
handler : function(){
}
};
menu = new Ext.menu.Menu([
secondLegal,
secondIllegal,
'-'
]);
menu.showAt(e.getPoint());
// 阻止浏览器弹出右键餐单
e.preventDefault();
});
3. //再Grid 中添加展开行
var expander = new Ext.grid.RowExpander({
tpl: new Ext.Template('<div style="padding-left:45px;font-size:12px;"><br><p><b>描述:</b><br/>{programmeIntro}</p><b</div>')
});
4.
var store = new Ext.data.JsonStore({
root: 'root',
totalProperty: 'sum',
url: 'url',
remoteSort: true,
fields: [
{ name: 'name' , mapping: 'name' },
{ name: 'num' , mapping: 'num' }
]
});
store.setDefaultSort('num' ,'DESC');
store.on('beforeload', function(store, options){
options.params = Ext.apply(options.params, {
method: 'grid',
taskId: Ext.getDom('taskId').value
});
});
var pagingBar = new Ext.PagingToolbar({
pageSize: 50,
store:store,
displayInfo: true,
emptyMsg:'没数据',
items:['-',
{ text: '' },'-',
'<div id=""></div>',
'<div id=""></div>'
]
});
var sm = new Ext.grid.CheckboxSelectionModel();
3. 分页变序号
Ext.grid.PagedRowNumberer = function(config){
Ext.apply(this, config);
if(this.rowspan){
this.renderer = this.renderer.createDelegate(this);
}
};
Ext.grid.PagedRowNumberer.prototype = {
width:20,
sortable:false,
fixed:false,
hideable:false,
rowspan: undefined,
renderer : function(v, p, record, rowIndex, colIndex, store){
if(this.rowspan){
p.cellAttr = 'rowspan="'+this.rowspan+'"';
}
var i = store.lastOptions.params.start;
if (isNaN(i)) {
i = 0;
}
i = i + rowIndex + 1;
i = Number(i).toString();
return i;
}
};
4. 改变行高
renderer:function(value,p,record){
return '<div style="height:15px">'+ value + '</div>';
}