最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Missing space when I change the cell's background color in SlickGrid? - Stack Overflow

programmeradmin4浏览0评论

I was trying to change cell's background color with custom formatter like this:

var myCellFormatter = function(row, cell, value, columnDef, dataContext) {
    if ((row + cell) % 5 == 1) {
        return "<div style='background-color:green'>" + value + "</div>";
    } else {
        return value;
    }
};

but this does not color the whole cell. There is some space between cell's div and the div in the formatter.

How could I color the whole cell ?

I was trying to change cell's background color with custom formatter like this:

var myCellFormatter = function(row, cell, value, columnDef, dataContext) {
    if ((row + cell) % 5 == 1) {
        return "<div style='background-color:green'>" + value + "</div>";
    } else {
        return value;
    }
};

but this does not color the whole cell. There is some space between cell's div and the div in the formatter.

How could I color the whole cell ?

Share Improve this question edited May 16, 2013 at 0:01 madth3 7,34412 gold badges52 silver badges74 bronze badges asked Apr 30, 2010 at 17:26 Misha MoroshkoMisha Moroshko 172k230 gold badges520 silver badges760 bronze badges 1
  • I found an efficient way to set styles on SlickGrid cells, without using an inner div. It's not trivial, but it does work well: stackoverflow./a/36562844/218294 – Sam Watkins Commented Apr 12, 2016 at 3:06
Add a ment  | 

1 Answer 1

Reset to default 4

Add a CSS class to that column (columnDefinition.cssClass="myCell") that would set the padding of the cell to 0px.

发布评论

评论列表(0)

  1. 暂无评论