Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81994

Do the JSON objects for joined table contents have not be named the same as a column?

$
0
0
I have a 1:N relationship (EQUIPMENT) working in my joined table, but adding a 1:1 (SPECIES_ID), which should be simpler, gives me a blank select box every time. I've spent hours checking and re-checking the generated JSON and the DT/Editor Javascript and I swear they are perfect.

I would try using a different column name, but I am hoping this isn't required because in my implementation it's pretty important they are the same: The column provides the table ID. It's also how the implementation determines if a join is 1:1 or 1:N.

Applicable code (trimmed):

Editor:
"fields": [
//...
	{"label": "Equipment:", "name": "EQUIPMENT[].id", "type": "checkbox" }, // works
	{"label": "Species:", "name": "SPECIES_ID.id", "type": "select" } // !works

DataTables:
	{"mData":"PARENT_RECIPE"},
	{
		"mData": "SPECIES_ID.name",
		"sDefaultContent": "foo"
	},
	{"mData":"EQUIPMENT", "mRender":"[, ].name"},
	/// ...

Some of the JSON "SPECIES_ID" object, appended to the JSON after "aaData"
	"SPECIES_ID": [{
		"value": "1",
		"0": "1",
		"label": "UNKNOWN (UNKNOWN)",
		"1": "UNKNOWN (UNKNOWN)"
	},
	{
		"value": "2",
		"0": "2",
		"label": "B (Boron)",
		"1": "B (Boron)"
	},...

An entry from aaData containing the species and equipment for one row:
		"SPECIES_ID": {
			"id": "3",
			"name": "P (Phosphorus)"
		},
		"EQUIPMENT": [{
			"id": "6",
			"name": "CIVAR11X"
		},
		{
			"id": "8",
			"name": "CIVAR62X"
		}],


The only thing I can think of is that DTE may not like SPECIES_ID being both a column name and a JSON object. I can't figure out why it would matter though as they are accessed and treated very differently as far as I can tell.
If not, does anyone have a theory as to why my select box is always empty?

Viewing all articles
Browse latest Browse all 81994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>