Input data to the table

Input data to the table

AndreyPetlyashenkoAndreyPetlyashenko Posts: 3Questions: 1Answers: 0

Hello everybody!
Need help
There is an object that comes with
server. This object has keys that contain an array of objects ( datas ). From each array, I want to output a property of objects and write the values ​​to a separate row in the table.
In other words, the number of table rows must be equal to the number of arrays in the object that comes from the backend.
Can I do it?
Here is the code:

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • AndreyPetlyashenkoAndreyPetlyashenko Posts: 3Questions: 1Answers: 0
    edited January 2021

    Sorry, I had to read it before the post.

    Here is the link for the test-case.

    https://codepen.io/andreypetlyashenko/pen/vYyEyvY?editors=1111

    As you can see, I have two arrays of data. Each array in my data is needed to draw for each row in the table.
    Thank you before-hand!

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    Looking at the data, it sounds like you just want to remove the keys from the objects and have that as an array, unless I'm missing something. So you just need:

     const arrData = Object.values(datas.data);
    

    then pass that into DataTables with data,

    Colin

  • AndreyPetlyashenkoAndreyPetlyashenko Posts: 3Questions: 1Answers: 0

    Thanks for your help! Everything worked after I had mapped the data to the right format)

This discussion has been closed.