question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[CDataTable] Allow nested objects / fields

See original GitHub issue

I would like to request support for nested objects / fields.

item: {
  id: 1,
  code: 'xx',
  unit: {
    description: 'myDescription'
  }
}

fields = [
  'id',
  'code',
  'unit.description'
]
<c-data-table :items="items" :fields="fields" />

This would result in a table with a description column with the value derived from the unit object. Currently if I do this the field value is undefined.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

5reactions
woothucommented, Feb 26, 2020

Hi! Scoped slots are made for unusual cases like this. Solution:

fields = [
  'id',
  'code',
  'unit'
]
<c-data-table :items="items" :fields="fields">
    <template #unit="{item}">
      <td>
          {{item.unit.description}}
      </td>
    </template>
</c-data-table>

3reactions
woothucommented, Feb 26, 2020

Yes, this is a valid use case, I get your point. 😉

Btw. You can keep your nested data, and just add an additional key to the item, just don’t mention nested data key in ‘fields’ prop. This way you preserve your desired structure and simplify CDataTable usage. Then computing could look like this

computed: {
  computedItems () {
    return rawItems.map(item => {...item, { unit: item.unit.description }})
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

DataTable - CoreUI
When set, displays table filter above table, allowing filtering by specific column. addTableClasses, (string | any[] | object). Adds classes to table element....
Read more >
javascript - Display collection of nested objects in DataTables
I want to display the above JSON in "DataTables". The nested objects in the IssueList should be displayed as a child table inside...
Read more >
Nested object data (objects) - DataTables example
The example below shows DataTables reading information for the columns from nested objects and arrays, where the structure of the row's data source...
Read more >
Solved: Create JMP datatable from C# DataTable variable
I could try nested for loops to loop through columns and rows and have JSL ... Columns.Add(column); // Create new DataRow objects and...
Read more >
Package 'data.table' - R Project
table;. i.e., it sees column names as if they are variables. This allows to not just select columns in j, but also compute...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found