您好,您这个需求实际上单纯设置数据验证无法实现,所以推荐用自定义单元格实现,
在示例的自定义单元格中,paint方法展示了绘制红圈标记的方法,您可以用paint方法中
的value来带入您的条件自行进行判断,如果满足(或不满足)条件时,绘制红圈进行提醒,
- CustomBase.prototype.paint = function (context, value, x1, y1, a1, b1, style, ctx) {
- if (!context) {
- return;
- }
- // 当标记为true时,绘制角标
- // 这里的条件可以改为用value判断
- if(this.showEffect){
- context.save();
- let base = a1 > b1 ? b1 / 2 : a1 / 2;
- context.beginPath();
- context.moveTo(x1 + a1, y1);
- context.lineTo(x1 + a1, y1 + base);
- context.lineTo(x1 + a1 - base, y1);
- context.fillStyle ='red';
- context.fill();
- context.closePath();
- context.restore();
- }
- oldPaint.apply(this, [context, value, x1, y1, a1, b1, style, ctx]);
- };
复制代码 |