我想更改已编辑的单元格HTML无效,我尝试在onCellChange
事件中执行此操作并通过getActiveCellNode
获取活动单元节点并更改它的HTML,问题是DOM更改不适用。
以下是代码:
grid.onCellChange.subscribe(function (evt, args) {
var $cell = $(grid.getActiveCellNode());
if (validateCell(grid.getActiveCell())) {
$cell.html('<div style="background: #FFCCCC" title="This field is invalid">Field invalid!</div>');
}
}
答案 0 :(得分:0)
//row equal grid row
//cell equal grid cell
//value is the value from the Dataview if you are using dv if not value of data in grid
//columnDef is the colum defination fro the colunm you are on
//dataContext is the object that makes up the row ie on item in dataview
function InvalidFormatter(row, cell, value, columnDef, dataContext) {
if(value == ckeck){ //dont know what your valid state is but you shoulld get the point
return '<span style="background: #FFCCCC" title="This field is invalid">Field invalid!</span>'
}
//or
if(dataContext[some propertiy from the dataview or row] == ckeck){ //dont know what your valid state is but you shoulld get the point
return '<span style="background: #FFCCCC" title="This field is invalid">Field invalid!</span>'
}
return '<span title="valid">'+value+'</span>';
}
//more here https://mleibman.github.io/SlickGrid/examples/example2-formatters.html
&#13;
这应该使用自定义格式化程序示例Custom Formatter
来实现