Datatable using 3 JSON sources

Datatable using 3 JSON sources

mattmadeymattmadey Posts: 1Questions: 1Answers: 0
edited March 2016 in Free community support

I have 3 JSON sources, which I'd like to dump into a datatable. The data is just two items for each source (module and tag). Below is an example of the data:

{"tag":"v2.1","module":"active_mq"}

The three sources are 3 different lifecycles QA\NP\PR. They will have the same module names, but different versions. I'd like to organize the data with the module name in one column, and the other 3 columns are QA\NP\PR, so I can see a comparison of versions in each lifecycle. I've tried concat'ing all the data, and keying off the module and tag, but the module names are duplicated in the module column. How should I go about sorting the data from each source into their respective columns, but keeping only unique values in the module column?

        //Load Data
        var jsonData = $.getJSON("//oser.somecompany.com/Data/GetData/puppet-modules-qa", function (qa_data) {
        var jsonData2 = $.getJSON("//oser.somecompany.com/Data/GetData/puppet-modules-np", function (np_data) {
        var jsonData3 = $.getJSON("//oser.somecompany.com/Data/GetData/puppet-modules-pr", function (pr_data) {

var combined_dc = qa_data.concat(np_data);
var combined_data = combined_dc.concat(pr_data);

                       // Render Datatable
                    $('#example').dataTable({
                        "aaData": qa_data,
                        "aoColumns": [
                            { "mDataProp": "module" },
                            { "mDataProp": "tag" },

                        ]
                    });
            });
       });
  });

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,771Questions: 1Answers: 10,510 Site admin

    It sounds like you basically need to built the data object to pass into the DataTable in the data option (or the legacy aaData option if you prefer).

    How you do that will depend very heavily upon the JSON data structure from your three feeds. In order ot be able to offer any help we'd need to know what data those feeds contain.

    Allan

This discussion has been closed.