如何在ng2智能表中使用Ng?

时间:2018-04-20 10:05:43

标签: angular angular2-forms angular2-services ng2-smart-table

上面我在pname(product_name)

中提到了我的Component.ts列名

这是一个下拉列表,所以我需要Ngfor按产品名称列出我不知道如何

在ng2智能表中添加Ngfor条件。

component.ts

this.service.get_type().subscribe(pro => {
       console.log(this.data=pro)
       console.log(this.val)
       this.settings = {
        mode: 'inline',
        hideSubHeader: false,

        add: {
          addButtonContent: '<i class="nb-plus"></i>',
          createButtonContent: '<i class="nb-checkmark"></i>',
          cancelButtonContent: '<i class="nb-close"></i>',
          confirmCreate :true,
        },
        edit: {
          editButtonContent: '<i class="nb-edit"></i>',
          saveButtonContent: '<i class="nb-checkmark"></i>',
          cancelButtonContent: '<i class="nb-close"></i>',
          confirmSave:true,
        },
        delete: {
          deleteButtonContent: '<i class="nb-trash"></i>',
          confirmDelete: true,
        },
        columns: {         
          slno: {
            title: 'S.No.',
            type: 'string',
            width:'1%',
          },
          ptype: {
            title: 'Product Type',
            type:'string',
            width:'50%',
            editor: {
              type:'list',
              config:{
                list:this.data
              }
            }

          },

          pname: {
            title: 'Product Name',
            type:'string',
            width:'35%',
            valuePrepareFunction: (data) => { return this.data[0]['type'] },

          },
          pdiscription: {
            title: 'Product Description ',
            type:'string',
            width:'50%',
          },
          qty: {
            title: 'QTY',
            type: 'string',
            width:'5%',
          },
          rate: {
            title: 'Rate',
            type: 'string',
            width:'5%',
          },
      amount: {
        title: 'Amount',
        type: 'string',
        width:'10%',
        valuePrepareFunction: (cell, row) => {
          console.log(row);
          console.log(row.id);
          return row.qty * row.rate
        },
      },

      tax: {
        title: 'Tax',
        selectMode: 'multi',
        filter: {
          type: 'checkbox',
          config: {
            true: 'Yes',
            false: 'No',
            resetText: 'clear',
          },
        },
        editor:{
          type: 'checkbox',
          config: {
            true: 'Yes',
            false: 'No',
            resetText: 'clear',
          }
        }
      }


},

   }
 },
    error => console.log(error));

上面我在pname(product_name)

中提到了我的Component.ts列名

这是一个下拉列表,所以我需要Ngfor按产品名称列出我不知道如何

在ng2智能表中添加Ngfor条件。

0 个答案:

没有答案