Table Headings?

Table Headings?

jsmythejsmythe Posts: 7Questions: 1Answers: 0

If I have my data structured like {"data":[MY_DATA_ARRAYS]}, I can use something simple like $('#example').DataTable( { "ajax": 'MY_DATA_LOCATION' } ) to create the cells of a table;

However, what can I use or do if my data is structured like {"headings":[MY_HEADINGS], "data":[MY_DATA_ARRAYS]} so I can dynamically create the headers without explicitly specifying them in a table's <th> blocks?

Replies

  • Rob BrunRob Brun Posts: 56Questions: 2Answers: 14

    Are you just trying to set the text of the <th> elements or create the <th> tags dynamically?

  • jsmythejsmythe Posts: 7Questions: 1Answers: 0
    edited June 2017

    I want to have the headers (i.e., the th tags) dynamically created based on the Ajax data that is received. This information will be contained in the headings array like the data is in the data arrays. I do NOT want to have the th's statically created since every query to the server may result in different headers, table sizes, etc.

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    If that is the case, you probably should pull your ajax out of the datatable and use the result set to define your columns and create your table

  • jsmythejsmythe Posts: 7Questions: 1Answers: 0

    That's what I want to do. However, how do I dynamically create the header information (e.g., fields information)?

This discussion has been closed.