ExtJS3.3 在grid里面调出一个colorMenu

{
id:'color',
name:'color',
header:'Color',
width:50,
sortable:true,
dataIndex:'color',
renderer: function(value, cellmeta, record,rowIndex,colIndex,store) {
var defaultColor
var display="<div style='background-color:"+record.data['color']+";width:10px;height:10px'></div>";
return display;
} ,
listeners:{
click(_this, The, rowIndex, e){
var colorMenu = new Ext.menu.ColorMenu({
handler: function(cm, color){
//Ext.Msg.alert('Color Selected', color);

//注意此处想要更换color时,如果只是修改secondGrid.store.getAt(rowIndex).data['color']=newColor; 是没有效果的,需要先把store该行的删了,在加进去,才有效果

//也需要注意的是extJs对参数顺序和个数有非常严格的规定,如果参数写的不对,一般不起效果

var newColor='#'+color;
secondGrid.store.getAt(rowIndex).data['color']=newColor;
var rc=secondGrid.store.getAt(rowIndex);
secondGrid.store.remove(secondGrid.store.getAt(rowIndex));
secondGrid.store.insert(rowIndex,rc);
secondGrid.store.reload();
}
});

colorMenu.showAt(e.getXY());
}
}
}

posted @ 2015-09-08 06:59  a5365958  阅读(235)  评论(0编辑  收藏  举报