2014-01-13 20 views
0

以我的方式,我使用此代碼突出顯示了我的GridView行。用Javascript恢復行CssStyle?

function onGridViewRowSelected(rowIdx) { 
    var selRow = getSelectedRow(rowIdx); 
    if (curSelRow != null) { 
     curSelRow.style.backgroundColor = 'transparent'; 
    } if (null != selRow) { 
     curSelRow = selRow; 
     curSelRow.style.backgroundColor = '#ababab'; 
    } 
    clearTimeout(rowHighLightTimeOut); 
} 

當我在我的GridView的碼定義AlternateRowCssStyle工作,但清除所有定義的備用CssStyle在GridView時的onmouseover。爲了防止這種情況,我需要捕獲當前的單元格樣式,並在onmouse時再次加載它? 我該怎麼做? 感謝

+0

感謝您的及時答覆。爲失誤抱歉。我編輯了代碼。此代碼工作,但需要恢復我的備用行css,以防止爲我的所有行應用「透明」背景。 –

回答

0

你可以嘗試這樣的事情:

function onGridViewRowSelected(rowIdx) { 
    var selRow = getSelectedRow(rowIdx); 
    if (curSelRow != null) { 
     curSelRow.style.backgroundColor = curRowSty; 
    } if (null != selRow) { 
     curSelRow = selRow; 
     curRowSty = curSelRow.style.backgroundColor; 
     curSelRow.style.backgroundColor = '#ababab'; 
    } 
    clearTimeout(rowHighLightTimeOut); 
} 
+0

感謝您的支持。爲我節省了很多。 –

0

你忘了使用style

curSelRow.style.backgroundColor = 'transparent'; 
+0

是的。爲失誤抱歉。修理它。 –