khu*_*boo 6 ng2-smart-table angular6
在我的应用程序中,我在ng2-smart-table的下拉列表中加载了动态值.现在我必须在ng2-smart-table中的下拉列表中启用多个选择.
注意:下拉列表中的多项选择不是复选框.
我想你可以尝试使用自己的自定义编辑器组件.我添加了一个select带有倍数的基础attribute,但您可以根据需要创建更复杂的自定义组件.
将数据传递给您的组件valuePrepareFunction并瞧.
settings.ts
private settings = {
// Previous config ...
columns: {
multiple: {
title: 'Multi select',
type: 'html',
editor: {
type: 'custom',
valuePrepareFunction: (cell, row) => row,
component: MultiSelComponent,
},
}
}
}
Run Code Online (Sandbox Code Playgroud)
multiSel.component.html
<select multiple [(ngModel)]="yourModelStore">
<option *ngFor="let item of myValues" [value]="item.value">{{item.name}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
multiSel.component.ts
import { Component, Input, OnInit } from '@angular/core';
import { ViewCell } from 'ng2-smart-table';
....
export class MultiSelComponent implements OnInit {
@Input() value;
yourModelStore: any; // rendered as this.yourModelStore = ['value', 'value'];
ngOnInit() {
this.myValues = this.value;
}
Run Code Online (Sandbox Code Playgroud)
module.ts
declarations:[
//others ...
MultiSelComponent
]
entryComponents: [
MultiSelComponent
]
Run Code Online (Sandbox Code Playgroud)
**我编辑了答案,并在设置和component.ts上添加了更多信息
| 归档时间: |
|
| 查看次数: |
2329 次 |
| 最近记录: |