亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

extjs 04_grid 單擊事件新發(fā)現(xiàn)

 更新時間:2012年11月27日 14:42:32   作者:  
EXTJS GRID 中單擊行和單元格獲得行或者單元格的內(nèi)容(數(shù)據(jù)),本文將整理此功能的應(yīng)用,需要了解的朋友可以參考下
EXTJS GRID 中 單擊行和單元格獲得行或者單元格的內(nèi)容(數(shù)據(jù))
Js代碼
復(fù)制代碼 代碼如下:

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','當前選中的數(shù)據(jù)是'+data);
}
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','當前選中的數(shù)據(jù)是'+data);
}

------------------------------------------------------------------------------
Js代碼
復(fù)制代碼 代碼如下:

grid.on('mouseover',function(e){//添加mouseover事件
var index = grid.getView().findRowIndex(e.getTarget());//根據(jù)mouse所在的target可以取到列的位置
if(index!==false){//當取到了正確的列時,(因為如果傳入的target列沒有取到的時候會返回false)
var record = store.getAt(index);//把這列的record取出來
var str = Ext.encode(record.data);//組裝一個字符串,這個需要你自己來完成,這兒我把他序列化
var rowEl = Ext.get(e.getTarget());//把target轉(zhuǎn)換成Ext.Element對象
rowEl.set({
'ext:qtip':str //設(shè)置它的tip屬性
},false);
}
});
grid.on('mouseover',function(e){//添加mouseover事件
var index = grid.getView().findRowIndex(e.getTarget());//根據(jù)mouse所在的target可以取到列的位置
if(index!==false){//當取到了正確的列時,(因為如果傳入的target列沒有取到的時候會返回false)
var record = store.getAt(index);//把這列的record取出來
var str = Ext.encode(record.data);//組裝一個字符串,這個需要你自己來完成,這兒我把他序列化
var rowEl = Ext.get(e.getTarget());//把target轉(zhuǎn)換成Ext.Element對象
rowEl.set({
'ext:qtip':str //設(shè)置它的tip屬性
},false);
}
});

---------------------------------------------------------------------------------
Js代碼
復(fù)制代碼 代碼如下:

listeners: {
'cellclick':function(grid,rowIndex,columnIndex,e ){ }
}
//這是單擊grid單元格時,觸發(fā)的事件
listeners: {
'cellclick':function(grid,rowIndex,columnIndex,e ){ }
}
//這是單擊grid單元格時,觸發(fā)的事件
Js代碼
grid.getView().getCell(rowIndex,columnIndex).style.background-color="#FF6600";
grid.getView().getCell(rowIndex,columnIndex).style.color="#FF6600";
grid.getView().getCell(rowIndex,columnIndex).style.background-color="#FF6600";
grid.getView().getCell(rowIndex,columnIndex).style.color="#FF6600";

我要改變都是整個背景色,不是光是字的顏色。還有怎么能點一個單元格時候,讓上次的點的單元格顏色恢復(fù)到原來呢???
把表格刷新下可以把以前單擊而改變的顏色還原,grid.getView().refresh(); 然后再讓這次單擊的單元格變色。
Js代碼
復(fù)制代碼 代碼如下:

grid.getView().refresh();
grid.getView().getCell(rowIndex,columnIndex).style.backgroundColor="#FF9999";

相關(guān)文章

最新評論