How To Convert Column To Row In Client-Side Datatable ?

How To Convert Column To Row In Client-Side Datatable ?

odydaharyodydahary Posts: 19Questions: 3Answers: 0

Hi All...
I'm really confused, I have data in a database with the following description:

And I expect the data on the client side to be displayed like the following image:

Can anyone help me? I have made some code in JSFiddle with following link:

https://jsfiddle.net/odydahary/vmgnwaLb/42/

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    How are you currently querying the database to get the data?

    A query on the second table with a left join to the teacher table would be the first step.

    Allan

  • odydaharyodydahary Posts: 19Questions: 3Answers: 0
    edited May 2022

    Thanks for your feedback Allan.
    I've handled the query, but when the data gets to the client side, I want the sub_criteria_id to line up sideways like a picture number 3.

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954

    If you are unable to build the table the way you want with a DB query then you will need to loop through the query results to build the three sub_criteria_id columns. You can do this in your server script before returning the data. Or you can use a Javascript loop and re-arrange the data before Datatables loads it. If you are using the ajax option you can use ajax.dataSrc to manipulate the json response.

    Kevin

  • odydaharyodydahary Posts: 19Questions: 3Answers: 0

    Thanks for your feedback Kevin.
    Yes, i wanna try that.

Sign In or Register to comment.