【问题标题】:angular 4 ng2-smart-table checkbox in column view列视图中的 angular 4 ng2-smart-table 复选框
【发布时间】:2017-10-27 03:57:11
【问题描述】:
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;
    }
}

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

【问题讨论】:

    标签: angular ng2-smart-table


    【解决方案1】:

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

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

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

    this.cell.getValue() //now you can access cell value 
    

    【讨论】:

    • 您是否也尝试过导入“编辑器”?
    猜你喜欢
    • 2018-12-31
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 2020-01-03
    • 2020-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多