-
xiaocesen 初学数据Lv2
发表于2021-11-19 19:54
楼主
ABI选中表元的样式脚本,脚本写在客户端脚本中哦~
计算后默认选中第一个表元:
选中时的样式:
此脚本中效果钻取表元的字体也会生效,同时还更改了钻取表元字体的悬停颜色以及取消下划线样式~此处设定在脚本末尾。
下方附上脚本代码:
- /*
- 设置单元格的选中背景色和选中字体颜色
- */
- var grid1 = g_rptpage.getGridById("GRID1");
- var grid2 = grid1.getCellDom('A1') ;
- var bgiurl = "url(vfs/root/products/ebi/sys/picture/a.png)";//背景图片地址
- var fcolor = "#00F"
- var time=0;
- grid1.selectedBgimage = bgiurl;
- grid1.selectedFontColor =fcolor;
- /*
- 设置选中表元的样式,cell为dom(td)
- */
- GridHtml.prototype.setCellStyle = function(cell){
- grid2.style.backgroundImage = "";//情况默认设置
- var bc = this.selectedBgimage;
- if (bc != cell.style.backgroundImage) {
- cell.style.backgroundImage = bc;
- cell.style.backgroundSize = "100% 100%";
- }
- grid2.childNodes[0].style.color = "";
- var selectedColor = this.selectedFontColor;
- if (selectedColor != cell.style.color) {
- //cell.style.color = selectedColor;
- cell.firstChild.style.color = selectedColor;//设置钻取表元字体颜色
-
- }
- ++ time ;
- };
- if (time == 0){//设置默认选中
- grid2.style.backgroundImage = bgiurl;
- grid2.firstChild.style.color = fcolor;
- grid2.style.backgroundSize = "100% 100%";
- };
- /*
- 恢复一个表元的样式
- */
- GridHtml.prototype.gobackCellStyle = function(cell) {
- var cellbgi= cell.style.backgroundImage;
- if (cellbgi = bgiurl) {
- cell.style.backgroundImage = "";
- cell.firstChild.style.color = "";
- }
- };
- EUI.addStyleSheet("#GRID1 a:hover {color: #00F !important;}");
- EUI.addStyleSheet("#GRID1 a:hover {text-decoration: none !important;");