vue.jsfrontendcore-ui

CoreUI Table read Object inside an Object


I am studying Vuejs and having a tutorial with implement CoreUI, I meet some challenge hope anyone can help me. Thanks

username: "admin"
email: "admin@gmail.com"
password: "$2a$10$gGKRtHqQHhdknGoHzt5II.ERWZS.ziPTNYEJ8N5Z.xTUY/PuxYNJC"
role: {
     id: 1
     name: "ADMIN"
}

This is my JSON object. May I know how to access role.name and display it in CoreUI TABLE? This is my field code for table ( but not working )

{ key: 'email', _style:'min-width: 50px', label: 'Email' },
            { key: 'password', _style: 'min-width:10px', label: 'Password'},
            { key: 'role.name', _style:'min-width:100px;', label: 'Role', filter: false, sorter: false },


Solution

  • You need to compute items to flat structure, before you pass them to CDataTable

    it is described on the updated url: https://coreui.io/vue/docs/3.2/components/table.html#custom-data-structures-and-filtering-sorting (Custom data structures and filtering/sorting section)