How do I set up multiselect filters on a table populated with JSON?

How do I set up multiselect filters on a table populated with JSON?

alulualulu Posts: 4Questions: 1Answers: 0

Hello, I am very new to coding and DataTables. I am trying to create a table with a multi-select dropdown exactly like this example here (found in another forum): http://live.datatables.net/xehexoye/1/edit. Instead of building my table completely in plain HTML as is shown in the example linked above, how can I achieve the exact result by pulling in data from a local JSON file in my repo (example URL: ./data/myJSON.json) and populating/filtering my data that way? My JSON is formatted like this if at all helpful:

[{
"staff": {
"Name": "Jane Doe"
"Birthday": "1999-08-07"
"Email": "janedoe@gmail.com"
}
},
{
"staff": {
"Name": "John Doe"
"Birthday": "1986-06-10"
"Email": "johndoe@gmail.com"
}
}]

Any guidance or a push in the right direction would be greatly appreciated!

Thanks!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,451Questions: 1Answers: 10,465 Site admin
    Answer ✓

    Use ajax to load your data. Specifically, see this example.

    Beyond that, as long as you have the header and footer in the table HTML, the code you linked to will work just fine (since it initComplete executes after the data has loaded for the table).

    Allan

  • alulualulu Posts: 4Questions: 1Answers: 0

    @allan Thank you so much for your help! I had accidentally removed the table footer when removing the table row data I didn't need from the original HTML that I used from the example and my filters showed up once I added the table footer back in. It looks and works great! I appreciate your time to answer my question :smile:

Sign In or Register to comment.