H
H
Herman Coffman2021-02-11 23:07:01
Vue.js
Herman Coffman, 2021-02-11 23:07:01

How to access an array within an array using a string in a quasar table?

There is a table from the examples on the quasar website . And in order to show some data in the columns of the table, we need to specify what

{ name: 'Name'', label: 'Label',  field: 'Field' },


and it will show us 3 in the column named Label.
const seed = [
  {
    name: 'Frozen Yogurt',
    calories: 159,
    Field: 3,
    carbs: 24,
    protein: 4.0,
    sodium: 87,
    calcium: '14%',
    iron: '1%'
  }


But what about when we need to get Field.someField (Array in our seed array)?
That is like this:

const seed = [
  {
    name: 'Frozen Yogurt',
    calories: 159,
    Field: [
    someField: 2,
    some: 1,
    Field: 3
    ],
    carbs: 24,
    protein: 4.0,
    sodium: 87,
    calcium: '14%',
    iron: '1%'
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Pastukhov, 2021-02-12
@Gera01

If you look at the dock
, then field can be set in 2 ways

{    
   // row Object property to determine value for this column
    field: 'name',
    // OR field: row => row.some.nested.prop,
}

So you need to look in this direction{ ..., field: row => row.Field.someField }

A
Alex, 2021-02-12
@Kozack Куратор тега Vue.js

Всегда можно сделать вычисляемое свойство в котором приводить данные к нужному формату.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question