1
import { Component } from '@angular/core';

import { DefaultEditor } from 'ng2-smart-table';

@Component({
    selector: 'checkbox-editor',
    //styleUrls: ['./editor.component.scss'],
    template: `
    <input [ngClass]="inputClass"
           type="checkbox"
           class="form-control"
           [name]="cell.getId()"
           [checked]="cell.getValue() == (cell.getColumn().getConfig()?.true || true)"
           (click)="onClick.emit($event)"
           (change)="onChange($event)">
    `,
})
export class RenderCheckboxComponent extends DefaultEditor {
    //CheckboxEditorComponent
    constructor() {
        super();
    }

    onChange(event: any): void {
        const trueVal = (this.cell.getColumn().getConfig() && this.cell.getColumn().getConfig().true) || true;
        const falseVal = (this.cell.getColumn().getConfig() && this.cell.getColumn().getConfig().false) || false;
        this.cell.newValue = event.target.checked ? trueVal : falseVal;
    }
}

“单元格”不在自定义视图上

4

1 回答 1

0

我认为您忘记将其导入自定义编辑器组件中。如果您需要自定义编辑器中的单元格,那么您需要导入它。所以像这样添加它

import { DefaultEditor,Cell } from 'ng2-smart-table';

现在您可以访问自定义组件中的单元格值。

this.cell.getValue() //now you can access cell value 
于 2017-10-20T23:57:55.637 回答