table用数据岛后,tr不能出现交替颜色
采用数据岛,按常规方法设置交替颜色,总不成功。跟踪发现tr 的sectionRowIndex不变一直为0。
很是郁闷,谁有成功的例子给一个,多谢!!
--------------------------------------------
部分代码如下,由于代码过于复杂,有些不相干的删除了。
下面的代码很杂,有些手写的,有些程序解析生成的,呵呵。内嵌的编辑控件,大家可不予考虑。
<table id='DesignDBGrid1bodytab' datasrc='#DesignDataSource3' border='1' bordercolor='#cccccc' frame=void style='border-collapse:collapse;table-layout: fixed;' class='dbgridbodytab'><tbody><tr style='font-family:宋体;font-size:9pt;font-weight:normal;font-style:normal;' class='dbgridbodyrow' onmouseover="dbrowmouseover(this)" onmouseout="dbrowmouseout(this)" onclick="dbrowclick(this)"><td style='width:100px;'><input type='text' datafld='ID' style='width:100px;text-align:Left;border:0;' onmouseout="dbgridtextout(this)" onclick="dbgridtextsel(this)" class='dbgridtext'></td><td style='width:100px;'><input type='text' datafld='STUDENT_ID' style='width:100px;text-align:Left;border:0;' onmouseout="dbgridtextout(this)" onclick="dbgridtextsel(this)" class='dbgridtext'></td><td style='width:100px;'><input type='text' datafld='SUBJECT' style='width:100px;text-align:Left;border:0;' onmouseout="dbgridtextout(this)" onclick="dbgridtextsel(this)" class='dbgridtext'></td><td style='width:100px;'><input type='text' datafld='MARK' style='width:100px;text-align:Left;border:0;' onmouseout="dbgridtextout(this)" onclick="dbgridtextsel(this)" class='dbgridtext'></td></tr></tbody></table>
-------------------------------------------
// JavaScript Document
// dbgrid数据行鼠标事件
function dbrowmouseover(obj) {
obj.className = "dbgridbodyrowover";
}
function dbrowmouseout(obj) {
obj.className = "dbgridbodyrow";
}
function dbrowclick(obj1){
var obj = event.srcElement;
alert("obj:"+obj.className+" index:"+obj.parentElement.parentElement.sectionRowIndex);
alert("obj1:"+obj1.className+" index:"+obj1.sectionRowIndex);
}
// dbgrid内嵌控件鼠标事件
function dbgridtextout(obj) {
obj.className = "dbgridtext";
}
function dbgridtextsel(obj) {
obj.className = "dbgridtextsel";
}
--------------------------------------------
css文件
.dbgridbodyrow{
height:20px;
background-color:expression((this.sectionRowIndex%2==0)?"#66FFCC":"#CCFF33");
}
.dbgridbodyrow td{
background-color:expression((this.parentElement.sectionRowIndex%2==0)?"#66FFCC":"#CCFF33");
}
.dbgridtext{
background-color:expression((this.parentElement.parentElement.sectionRowIndex%2==0)?"#66FFCC":"#CCFF33");
border-color:expression((this.parentElement.parentElement.sectionRowIndex%2==0)?"#66FFCC":"#CCFF33");
border-width:1px;
border-style:solid;
}
.dbgridbodyrowover{
background-color:#0099CC;
}
.dbgridbodyrowover td{
background-color:#0099CC;
}
.dbgridbodyrowover td .dbgridtext{
background-color:#0099CC;
border-color:#0099CC;
border-width:1px;
border-style:dashed;
}
.dbgridtextsel{
border-color:#FF0000;
border-width:1px;
border-style:solid;
}