Ng2-smart-table:在内联编辑中使用下拉菜单或日期选择器

Pra*_*Sam 4 ng2-smart-table angular

我正在为Angular2寻找更好的表格表示,并发现ng2-smart-table很好用.但问题是它似乎没有提供在内联编辑中使用下拉列表或日期选择器的直接方法.

有没有办法使它成为可能或我可以用什么替代组件来代表我的Angular2应用程序中的表视图.

Amp*_*esh 6

对于datepicker:

在设置[.ts]

settings={
columns:{
// other columns here

dob: {//date of birth
        title: 'yyyy/mm/dd hh:mm',
        type: 'html',
        editor: {
          type: 'custom',
          component: DoBComponent,
        },
   }
}
Run Code Online (Sandbox Code Playgroud)

在dob.component.html中

<owl-date-time autoClose [(ngModel)]="datevalue" dataType="string" 
 (click)="updateValue()">
</owl-date-time>
Run Code Online (Sandbox Code Playgroud)

在dob.component.ts中

datevalue: any;
  updateValue(){
    console.log(this.datevalue);
    this.cell.newValue = this.datevalue;
  }
where your DoBComponent extends DefaultEditor
Run Code Online (Sandbox Code Playgroud)

在你的module.ts中

     declarations:[
//other compnents here
        DoBComponent
     ]
     entryComponents: [
      DoBComponent
    ]
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助 !!!

参考:https://www.npmjs.com/package/ng-pick-datetime, https://akveo.github.io/ng2-smart-table/#/examples/custom-editors-viewers


小智 5

我发现了类似这样的下拉菜单:

private settings = {
  columns: {
    name: {
      title: 'Name'
    },
    valid: {
      title: 'Valid',
      type: 'html',
      editor: {
        type: 'list',
        config: {
          list: [
            {value: true, title: 'Valid'},
            {value: false, title: 'Not valid'}
          ],
        },
      }
    }, //... more columns
  }
}
Run Code Online (Sandbox Code Playgroud)