angularng2-smart-table

how to display an object in one row of smart table


entity from MongoDB enter image description here

I want to display those 3 attributes "currencyCode, Amount, serialData" in one case of table.

I'm using ng2-smart-table with angular 11 and I'm try this code but nothings work

      dateTime: {
        title: 'Date & Time',
      },
      montant: {
        title: 'Montant',
      },      
      serialNbr: {
        title: 'serialNbr',
          CurrencyCode: {
            valuePrepareFunction: (row) => { return row.serialNbr.CurrencyCode }
          },
          Amount: {
            valuePrepareFunction: (row) => { return row.serialNbr.Amount }
          },
          SerialData: {
            valuePrepareFunction: (row) => { return row.serialNbr.SerialData }

          },
      },


Solution

  • i fix my issue perfectly and i share this code to help anyone else have the same problem, if you have a nested field or a field that is an array of objects enter image description here

    dateTime: {
            title: 'Date & Time',
          },
          montant: {
            title: 'Montant',
          },      
          serialNbr: {
            title: 'Serial Number',
            valuePrepareFunction: (serialNbr) => {
              return serialNbr.map(s => "" + s.CurrencyCode + ","+s.Amount+","+s.SerialData+" ").toString()
            }  
          },