ng2-smart-table
ng2-smart-table copied to clipboard
can't set editable to "false" on a custom editor
i have created a custom editor wit datapicker. only users with authorisation should change the date, so i need to disable this cell. but i it not working.
my custom editor code:
template.html:
<input [(ngModel)]="dateModel"
[owlDateTimeTrigger]="dt3"
[owlDateTime]="dt3">
<owl-date-time [pickerType]="'calendar'" (afterPickerClosed)="updateValue()" #dt3>
@Component({ selector: 'datepicker-cell-view', templateUrl: template.html, }) export class DatepickerCellComponent extends DefaultEditor { cellValue: any; dateModel: any; constructor( public dateFormat: DatePipe, ) { super(); } updateValue() { this.cell.newValue = this.dateFormat.transform(this.dateModel, 'dd.MM.yyyy'); } ngOnInit() { this.cell.getValue() != '' ? this.dateModel = new Date(this.dateFormat.transform(this.cell.getValue(), 'dd.MM.yyyy HH:mm')) : this.dateModel = Date.now(); } }
and i add it to cols like this:
_cols['date'] = { title: 'date', type: 'html', editable: false, editor: { type: 'custom', editable: false, component: DatepickerCellComponent, }, }
editable: false is not working! what is wrong?
is it possible to set editable to false on a custom editor?
Hi I just figured it out: add [disabled]="!cell.isEditable()"
to your input tag and remove editable: false, from editor: {
type: 'custom',
editable: false,
component: DatepickerCellComponent,
},
for more info see this example: https://github.com/akveo/ng2-smart-table/blob/master/projects/demo/src/app/pages/examples/custom-edit-view/custom-editor.component.ts
Hi, i came across the same requirement but the solution provided above is not fitting to my problem. below is the snippet of my ng2-smart-table
roles: { title: 'Views', type: 'custom', filter: false, editable: false, editor: { type: 'custom', editable: false, component: ViewWindowRenderComponent, }, valuePrepareFunction: (cell, row) => row, renderComponent: ViewComponent, }, So, i want to disable this column whenever add new is clicked. Thanks in advance for you assistance.