Joined Tables demo confusion

Joined Tables demo confusion

burncharburnchar Posts: 118Questions: 12Answers: 0
edited September 2012 in Editor
I am trying to implement the joined table functionality of the Editor (commercial license) and am fairly confused over how to move forward.

Consider the following snippet (from the syntax-colored code in http://editor.datatables.net/release/DataTables/extras/Editor/examples/join.html ):

[code]
// Use the 'name' property from the 'dept' object in the
// JSON. It might not be set, so we also provide a default.
"mData": "dept.name",
"sDefaultContent": ""
[/code]

---------

Using [code]"sAjaxSource": "php/join.php"[/code] I figured out the absolute URI to get the AJAX source data is:
http://editor.datatables.net/release/DataTables/extras/Editor/examples/php/join.php

(It would be nice if I didn't have to do this -- see previous post today, "Documentation hopes". Maybe I'm missing something though.)

The actual contents of the 'dept' object are as follows:

[code]
"dept":[
{
"value":"1",
"0":"1",
"label":"IT",
"1":"IT"
},
{
"value":"2",
"0":"2",
"label":"Sales",
"1":"Sales"
},
// **** trimmed for brevity... ****
{
"value":"7",
"0":"7",
"label":"Support",
"1":"Support"
}
]
[/code]

I don't get it. Where is the 'name' property?
Where is the 'id' property mentioned in the following code:

[code]
{
"label": "Department:",
// The 'id' value from the property is used to set the value
// of the select list.
"name": "dept.id",
"type": "select"
}
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You've only picked a small amount of the JSON that is returned from the server in the demo there. The rest of it looks like this:

    [code]
    {
    "id": -1,
    "error": "",
    "fieldErrors": [],
    "data": [],
    "aaData": [{
    "DT_RowId": "row_1",
    "first_name": "Quynn",
    "last_name": "Contreras",
    "dept": {
    "id": "1",
    "name": "IT"
    },
    "access": [{
    "id": "1",
    "name": "Printer"
    }, {
    "id": "3",
    "name": "Desktop"
    }, {
    "id": "4",
    "name": "VMs"
    }],
    "extra": {}
    },
    [/code]

    Going back to edit my post in your other thread based on this... :-)

    Allan
  • burncharburnchar Posts: 118Questions: 12Answers: 0
    Please move this to the editor forum. I am not sure how I ended up posting it in General.
This discussion has been closed.