欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間: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','當(dāng)前選中的數(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','當(dāng)前選中的數(shù)據(jù)是'+data);
}

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

grid.on('mouseover',function(e){//添加mouseover事件
var index = grid.getView().findRowIndex(e.getTarget());//根據(jù)mouse所在的target可以取到列的位置
if(index!==false){//當(dāng)取到了正確的列時(shí),(因?yàn)槿绻麄魅氲膖arget列沒(méi)有取到的時(shí)候會(huì)返回false)
var record = store.getAt(index);//把這列的record取出來(lái)
var str = Ext.encode(record.data);//組裝一個(gè)字符串,這個(gè)需要你自己來(lái)完成,這兒我把他序列化
var rowEl = Ext.get(e.getTarget());//把target轉(zhuǎn)換成Ext.Element對(duì)象
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){//當(dāng)取到了正確的列時(shí),(因?yàn)槿绻麄魅氲膖arget列沒(méi)有取到的時(shí)候會(huì)返回false)
var record = store.getAt(index);//把這列的record取出來(lái)
var str = Ext.encode(record.data);//組裝一個(gè)字符串,這個(gè)需要你自己來(lái)完成,這兒我把他序列化
var rowEl = Ext.get(e.getTarget());//把target轉(zhuǎn)換成Ext.Element對(duì)象
rowEl.set({
'ext:qtip':str //設(shè)置它的tip屬性
},false);
}
});

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

listeners: {
'cellclick':function(grid,rowIndex,columnIndex,e ){ }
}
//這是單擊grid單元格時(shí),觸發(fā)的事件
listeners: {
'cellclick':function(grid,rowIndex,columnIndex,e ){ }
}
//這是單擊grid單元格時(shí),觸發(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";

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

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

相關(guān)文章

最新評(píng)論