Multiple tables with different granularity from one dataset?

Multiple tables with different granularity from one dataset?

thomasjbarrettthomasjbarrett Posts: 2Questions: 1Answers: 0

Can DataTables display multiple tables on 1 page from 1 dataset, but with a different granularity on each table?

For example, let's say I have a dataset of contractors with their name, location, projects, and time spent:
* "John Smith", "Florida", "Project A", "8 hrs"
* "John Smith", "Florida", "Project B", "12 hrs"
* "Jane Doe", "Virginia", "Project A", "10 hrs"

And then I wanted 2 tables from that dataset: one for the contractor info, and another for the project info:

Table One:
* "John Smith", "Florida"
* "Jane Doe", "Virginia"

Table Two:
* "Project A", "18 hrs"
* "Project B", "12 hrs"

I've been searching through the API docs for a way to do this in 1 AJAX call for the flat data and using DataTables to generate the tables from that, but I'm not seeing it. Any pointers on how to accomplish this, or "no it's not possible" is appreciated, thanks.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 16,111Questions: 25Answers: 3,815

    You can use a jQuery ajax() request to fetch the data then populate each Datatable in the success function. This example will give you an idea of what to do.
    http://live.datatables.net/huyexejo/1/edit

    Kevin

  • colincolin Posts: 14,303Questions: 1Answers: 2,431

    Yep, that's possible, and fairly straightforward if the data set is small - see example here. If the data becomes large, you may want to rejig the data on server to give it in the expected format.

    Colin

  • colincolin Posts: 14,303Questions: 1Answers: 2,431
    Answer ✓

    Ignore that last link, it didn't save the last set of edits! This here is the final solution: http://live.datatables.net/rimikepu/1/edit

    Colin

  • thomasjbarrettthomasjbarrett Posts: 2Questions: 1Answers: 0

    Thanks much, turns out our datasets are too large for this as a solution, so we'll stick with the server giving it in the expected formats.

This discussion has been closed.