我为复选框输入创建了单元格渲染器,但当我单击复选框时,它会更改单元格内的值,但不会更改单元格上的值。
参见Plunker示例:Plunker
refresh方法应该在更改时调用,但无论如何它不是。
onCellClicked无论我如何单击复选框,函数都返回相同的值。
我尝试用两个可能的值cellEditor: 'agRichSelect'true进行false操作,效果很好,但我需要复选框。
他有什么想法!

最佳答案

First,要跟踪ngModel的更改,需要使用(ngModelChange)而不是(onChange)
其次,不应该使用params.value进行ngModel绑定,params-是grid的一部分,所以要避免混合,并单独保存。
Third,在refresh函数内部,不应更新cellRendererparams函数内部用于refresh

// Mandatory - Get the cell to refresh. Return true if the refresh succeeded, otherwise return false.
// If you return false, the grid will remove the component from the DOM and create
// a new component in its place with the new values.
refresh(params: any): boolean;

第四,如果要更新grid中的值,应该使用cellRenderer接口,而不是ICellEditorCompICellRendererCompICellRendererAngularCompICellEditorAngularComp情况下)
第五,您忘记在Angular中设置复选框字段editable: true
最后一个-您刚刚创建了一个复选框(超出columnDefs范围),它看起来像一个工作示例,但实际上不是。
如果grid,您需要了解完整的编辑过程,因此只需检查这里有关cell renderingcell editing和更多的详细信息。
以及here您可以看到exactly自定义复选框渲染器将如何工作:
function booleanCellRenderer(params) {
    var valueCleaned = booleanCleaner(params.value);
    if (valueCleaned === true) {
        return "<span title='true' class='ag-icon ag-icon-tick content-icon'></span>";
    } else if (valueCleaned === false) {
        return "<span title='false' class='ag-icon ag-icon-cross content-icon'></span>";
    } else if (params.value !== null && params.value !== undefined) {
        return params.value.toString();
    } else {
        return null;
    }

}

09-25 16:58
查看更多