Cannot store userdata in rows using JSON

Using the exact syntax displayed in these docs:
docs.dhtmlx.com/doku.php?id=dhtm … _templates

I cannot get userdata from JSON to be automatically added to the rows. The values keep coming back empty. I’ve exported the target grid as rg for testing:

rg.getUserData(1234, "name1"); // "" rg.setUserData(1234, "name1", "asdf"); // undefined rg.getUserData(1234, "name1"); // "asdf"

Using json (ugly copy-paste from debug console, trust me it’s proper, my grid is filled up)

details: Object rows: Array[19] 0: Object data: Array[2] 0: "12:35:51" 1: null length: 2 __proto__: Array[0] id: 1234 style: "color:green" userdata: Object name1: "ud1" name2: "ud2"

Here is a workaround for this problem to add the userdata manually:

	// Insert new contents
	rowGrid.parse(data, 'json');

	// Fix DHTMLX userdata AFTER inserting contents
	for (var i = 0; i < data.rows.length; i++) {
		var row	= data.rows[i];
		var id	= row.id;
		var userdata = row.userdata;
		for (var key in userdata) {
			if (userdata.hasOwnProperty(key)) {
				var val = userdata[key];
				rowGrid.setUserData(id, key, val);
			}
		}
	}

Please, try to include the dhtmlxgrid_json.js library.
You can find in the “dhtmlxgrid/codebase/ext” directory.

But the json is (apart from userdata) already being parsed correctly, the griddata works. I am using dhtmlx_std_full, so (according to the documentation) everything is included already, right?

Unfortunately the dhtmlxgrid_json.js library is included in PRO version only.

Ah okay, thank you. :slight_smile: