Reputation: 473
I call the function tabulator() with these params.
$("#tableObj").tabulator("addRow", {id:1, Name:"John", Age:"20"}, true);
I want to pass the Array elements name dynamically,
read from a Json ( '{id:1, Name:"John", Age:"20"}' )
.
I mean that column names will change.
Ex : {id:1, Company:"myComp", Address:"myaddress"}
How can I create theses objs from Strings or JSon text?
Upvotes: 1
Views: 97
Reputation: 3020
You could use JSON.parse
but be aware that id:1, Name:"John", Age:"20"
is NOT valid JSON. The keys must be wrapped in quotes, otherwise it will produce an error.
var str = '{"id":1, "Name":"John", "Age":"20"}';
var obj = JSON.parse(str);
$("#tableObj").tabulator("addRow", obj, true);
Upvotes: 1