I see you have a grid defined as html and parsed out, like Dojo.
Does it make sense to have a grid defined as JSON that could do something like
grid = new Grid(json);
I guess its the advanced functionality with functions and the like where you would run into limitations but I could see how it could be more convenient for the server to generate json for simple tables.
Re: json to grid
Posted: Sat Mar 27, 2021 5:56 pm
by mats
Sure, you can generate a grid however you want. Simple scenarios can for sure be described as pure JSON as you discovered.
Re: json to grid
Posted: Fri Oct 22, 2021 2:46 pm
by Animal
I'm not sure where you are getting your impressions from.
new Grid({ object notation }) is exactly how it works.
You pass an object.
JSON is a string encoding of an object. So if you have JSON, you need to use JSON.parse to turn it into an object, then pass it to the Grid constructor. It's that simple.
Re: json to grid
Posted: Fri Oct 22, 2021 6:03 pm
by gregc
What was confusing was when I create the grid I have code like
Its not something I would tackle any time in the next year I think, when I originally asked it was because I could have written better server side java code by creating a single java class that was the grid and then send it as json to the front end to be created. But I couldn't understand how the dynamic javascript code in processtimes could be represented as json.
processItems({ items, record, column }) {
for (var key in items) {
var item = items[key];
if (item.text && item.text.includes("quals")) {
item.hidden = true;
}
if (window.genericgrid && window.genericgrid.selectedRecords && window.genericgrid.selectedRecords.length > 1) {
if (item.text && item.text.includes("Copy")) {
item.hidden = true;
}
if (item.text && item.text.includes("Edit")) {
item.hidden = true;
}
}
}
}, }
},
Not too important right now, just my confusion with javascript and json.
Re: json to grid
Posted: Mon Oct 25, 2021 1:11 pm
by mats
Right, JS functions are not part of the JSON specification (it's a data protocol) so you would need to handle that some other way.