I was able to easily modify the custom XML to handle standard JSON:
function process_strongloop_row(r, json) {
//sets just a plain array as no custom attributes are needed
r._attrs = {};
for (j = 0; j < r.childNodes.length; j++) r.childNodes[j]._attrs = {};
//finishes data loading
var data = _(json).toArray()
this._fillRow(r, data);
return r;
}
function get_strongloop_data() {
}
function process_strongloop(data) {
'use strict';
this._parsing = true;
var json = JSON.parse(data.response);
for (var i = 0; i < json.length; i++) {
var id = this.getUID();
this.rowsBuffer[i] = { //stores references to each row element
idd: id,
data: json[i],
_parser: this._process_strongloop_row, //cell parser method
//_locator: this._get_strongloop_data //data locator method
};
this.rowsAr[id] = json[i]; //stores id reference
}
this.render_dataset(); //forces update of grid's view after data loading
this._parsing = false;
}
As you can see - it is a pretty straight forward handling of JSON structure, and simply making it as an Array per row.
The reason it was needed - I’m using StrongLoop CRUD methods, which are returning records/objects from the database without the “rows” array.
Couple of questions:
Isn’t there a simpler way of doing it instead of custom data processor?
shouldn’t there by an additional type on DHTMLX level - maybe json_rows which is only accepting the rows - just like this Data processor?
I looked online - and I couldn’t find an example for the _locator method. Any one has a reference to a working example?
which managed to set the grid configuration, and only then, the following worked:
grid.load(‘http://10.0.0.215:3000/api/packages’, ‘js’);
which is great!
But I need dhtmlXDataStore to work the same way… and I can’t figure out how.