hbpqwxh 发表于 2019-7-10 14:27:53

如何隔行设置grid的颜色?

想要给grid单数行和双数行设置不同的颜色,且reload之后颜色不丢失,请问该怎么改?

hbpqwxh 发表于 2019-7-10 17:03:44

怎么没有人回答

dforce 发表于 2019-7-11 09:14:16

可以使用斑马线
http://www.miniui.com/demo/#src=datagrid/alternating.html

hbpqwxh 发表于 2019-7-11 09:40:41

是这样吗?
<style type="text/css">
    .sx
    {        
      background-color:#97FFFF;
    }
    .xx
    {        
      background-color:#9AFF9A;
    }
    </style>
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {

                if (i%2==0)
                   e.row..rowCls= = 'sx';
                 else
                  e.row..rowCls= = 'xx';
            }
            return "";
        }

dforce 发表于 2019-7-11 11:01:29

hbpqwxh 发表于 2019-7-11 09:40 static/image/common/back.gif
是这样吗?

    .sx


http://www.miniui.com/demo/#src=datagrid/drawcell.html
参考示例,可以绘制行背景色

hbpqwxh 发表于 2019-7-11 11:01:47

dforce 发表于 2019-7-11 09:14 static/image/common/back.gif
可以使用斑马线
http://www.miniui.com/demo/#src=datagrid/alternating.html

是这样吗?
<style type="text/css">
    .sx
    {        
      background-color:#97FFFF;
    }
    .xx
    {        
      background-color:#9AFF9A;
    }
    </style>
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {

                if (i%2==0)
                   e.row..rowCls= = 'sx';
                 else
                  e.row..rowCls= = 'xx';
            }
            return "";
        }

dforce 发表于 2019-7-11 11:18:17

hbpqwxh 发表于 2019-7-11 11:01 static/image/common/back.gif
是这样吗?

    .sx

不是,参考示例用ondrawcell事件处理
另外miniui问题请发第一个版块

hbpqwxh 发表于 2019-7-11 13:47:37

dforce 发表于 2019-7-11 11:18 static/image/common/back.gif
不是,参考示例用ondrawcell事件处理
另外miniui问题请发第一个版块

怎样才能取到是第几行呀?
这个里面没有怎么取偶数行的代码呀?
grid.on("drawcell", function (e) {
}

dforce 发表于 2019-7-11 14:58:50

hbpqwxh 发表于 2019-7-11 13:47 static/image/common/back.gif
怎样才能取到是第几行呀?
这个里面没有怎么取偶数行的代码呀?
grid.on("drawcell", function (e) {


var row=e.record;
var index=grid.indexOf(row);
可以根据行序号来判断是奇数还是偶数行

hbpqwxh 发表于 2019-7-12 09:07:16

dforce 发表于 2019-7-11 14:58 static/image/common/back.gif
var row=e.record;
var index=grid.indexOf(row);
可以根据行序号来判断是奇数还是偶数行 ...

已经解决,谢谢!
页: [1]
查看完整版本: 如何隔行设置grid的颜色?