Print an object into rows, but detect the object number as the total content in the pagination

Print an object into rows, but detect the object number as the total content in the pagination

vincent11abvincent11ab Posts: 2Questions: 0Answers: 0

Hello, i have a necessity to make datatable to work like this

I've successfully made the datatable work beforehand, already prepared the incoming json to be manipulated further if necessary, then i was thinking, is that even possible? Because i already tried to read objects that contained array of objects, and the result is like this

This is my json content https://pastebin.com/1BLp9nC6

Is this doable from frontend side? Thanks before, I'm really stuck on this one

Replies

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    I'm not too clear on what you're trying to do, but this example may help. It's showing how to use nested data. If not, please can you explain more, and create a test case that we can work with. 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

  • vincent11abvincent11ab Posts: 2Questions: 0Answers: 0

    Thanks for the reply, sorry i think i forgot to put the issue i had, my bad.

    Ok so I use Datatable regularly, but i always take the data from the database normally (no fancy requirement like i had right now), for example i have a table of users from the table like this:

    The data i took from the database is an array of objects, let's say {id: "", username: ""}, this case is pretty normal and Datatable able to consume it without problem, even if i ever need a deep nested data (like from your example), we can put let's say userlist[].id or userlist[].username in the column.

    And using my recent picture, the result from the API is exactly 9 rows, hence 1 to 9 of 9 entries.

    However, the requirement i had now is exactly like the first picture, so even though i have 13 rows there, those 13 rows there actually contained within 3 objects, and i need those 13 rows able to be treated as 3 "rows" so the datatable will read it as 3 objects only.

    This requirement is essential due to the needs of pagination, so for example i put the limit of one page as 10 rows, it is actually not 10 literal rows but instead 10 objects (which actually contained more than 10 rows in reality).

    I hope my explanation described my needs more clearly, also i will try to make a test case, i'll link it down below, thanks before!

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    That helps, thanks, but the test case would help more. If you could post the data you're receiving and the table layout you want in a test case (the link is in my last message) that'll help progress this,

    Colin

Sign In or Register to comment.