handsontable教程_handsOnTable单元格着色

I have a Handsontable table filled with data and already rendered

After checking the cells, I have located a couple of cells of interest and would like to color them - is there a good way to do this using the Handsontable code?

Please note this is after loading and rendering the table

Edit:

The table is rendered with basic options:

$container.handsontable({

startRows: 8,

startCols: 6,

rowHeaders: true,

colHeaders: true,

minSpareRows: 1,

minSpareCols: 1,

//contextMenu: false,

cells: function (row, col, prop) {

}

});

And the data is loaded via Ajax, decode_file.php reads an excel sheet and returns data as JSON:

$.ajax({

url: "decode_file.php",

type: 'GET',

success: function (res) {

handsontable.loadData(res.data);

console.log('Data loaded');

},

error: function (res) {

console.log("Error : " + res.code);

}

});

After loading the data, the user clicks a "Process" button and the code looks for a cell with the text "Hello world". Let's say the code finds the text "Hello World" in cell row 4/col 5 and changed the background color of cell row 4/col 5 to red

解决方案

The homepage provides a good example for your purpose:

Just modify the condition (in this case upper/left corner).

cells: function (row, col, prop) {

if (row === 0 && col === 0) {

return {type: {renderer: greenRenderer}};

}

}

and you're done.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值