【问题标题】:checkboxes in ng2-smart-tableng2-smart-table 中的复选框
【发布时间】:2018-12-31 23:35:48
【问题描述】:

我在我的项目中使用 ng2-smart-table,我想添加一个带有复选框的列,在渲染时将根据绑定表的对象进行检查。 在对象中,有一个带有布尔值的字段,它将确定是否选中复选框,并且在对复选框进行更改后,更改的值应该可用。

【问题讨论】:

    标签: angular ng2-smart-table


    【解决方案1】:

    您需要设置过滤器类型复选框

    passed: {
        title: 'Passed',
        filter: {
          type: 'checkbox',
          config: {
            true: 'Yes',
            false: 'No',
            resetText: 'clear',
          },
        },
      },
    

    在您的数据中,您需要传递复选框值

    data = [
    {
      id: 4,
      name: 'Patricia Lebsack',
      email: 'Julianne.OConner@kory.org',
      passed: 'Yes',
    },
    ]
    

    试试这个例子Checkbox, Select and Completer filter types

    【讨论】:

      【解决方案2】:

      我现在无法为您提供完整的示例代码,但您应该为您的复选框定义一列。为该列提供一个布尔值。不要忘记添加

      '类型:自定义'

      它呈现您提供的组件。我使用了一个名为 MyCheckboxComponent 的组件

      <nb-checkbox [ngModel]="selected"></nb-checkbox>
      

      nb-checkbox 在星云库中。

      settings = {
          columns: {
              checkBox: {
                type: 'custom',
                filter: false,
                width: '10px',
                renderComponent: MyCheckboxComponent
          }
        }
      }
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-08
      • 1970-01-01
      • 1970-01-01
      • 2019-01-08
      • 2020-01-03
      • 1970-01-01
      • 2018-09-21
      相关资源
      最近更新 更多