AJAX call with nested JSON Data

AJAX call with nested JSON Data

leesuttonleesutton Posts: 2Questions: 1Answers: 0
edited January 2020 in Free community support

I have a json source that I'd like to use inside a DataTable:

{
  "tickets" : [ {
    "ticket" : {
      "locator" : "QWF2A8C6",
      "status" : "new"
    }
  }, {
    "ticket" : {
      "locator" : "DNW18Y5T",
      "status" : "new"
    }
  }, {
    "ticket" : {
      "locator" : "V3W32JFB",
      "status" : "new"
    }
  } ]
}

In the ajax definition, 'tickets' has been added as the source to replace 'data' and the datatable is aware and shows 3 rows.

 "ajax": {
            "dataSrc": "tickets",

With the column defs:

columnDefs: [
                {
                    title: "Locator",
                    data: "ticket.locator",
                    targets: 0
                },

            ],

I've tried a number of 'data' definitions without success. They all result in a "DataTables warning: table id=dataTable - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4" error.

Can DataTables include data in this format? What would the correct syntax for the columnDef for data (ticket.locator does not work)?

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

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.