What is the simplest way to dynamically load a table from a local JSON file?
I have struggled for hours to do this without any luck and would appreciate
some insight.
Below is a sample that works when referencing an embedded javascript array
object (data):
qx.Class.define("iveware.Application",
{
extend : qx.application.Standalone,
members :
{
main : function()
{
var data = [
{id:3, variable:"age", label:"",variableType:"", restrict:"",
bounds:""},
{id:4, variable:"gender", label:"",variableType:"", restrict:"",
bounds:""},
{id:5, variable:"race3", label:"",variableType:"", restrict:"",
bounds:""},
{id:6, variable:"hyper", label:"",variableType:"", restrict:"",
bounds:""},
{id:7, variable:"diab", label:"",variableType:"", restrict:"",
bounds:""},
{id:8, variable:"smoke", label:"",variableType:"", restrict:"",
bounds:"" },
{id:9, variable:"numcig", label:"",variableType:"", restrict:"",
bounds:""},
{id:10, variable:"yrssmoke", label:"",variableType:"", restrict:"",
bounds:""},
{id:11, variable:"fatindex", label:"Fatindex scale",variableType:"",
restrict:"", bounds:""},
{id:12, variable:"fammi",label:"",variableType:"", restrict:"",
bounds:"" },
{id:13, variable:"edusubj3",label:"",variableType:"", restrict:"",
bounds:"" },
{id:14, variable:"dha_epa", label:"Dietary N-3
intake",variableType:"", restrict:"", bounds:""},
{id:15, variable:"redtot", label:"Red cell membrane
value",variableType:"", restrict:"", bounds:""},
{id:16, variable:"cholesth",label:"",variableType:"", restrict:"",
bounds:""}
];
this.base(arguments);
if (qx.core.Variant.isSet("qx.debug", "on"))
{
qx.log.appender.Native;
qx.log.appender.Console;
}
var win = new qx.ui.window.Window("Variable Parameters").set({
layout : new qx.ui.layout.Grow(),
allowClose: true,
allowMinimize: false,
contentPadding: 0
});
this.getRoot().add(win);
win.moveTo(200, 200);
win.open();
var tableModel = new qx.ui.table.model.Simple();
tableModel.setColumns([ "ID", "Variable", "Label", "VariableType",
"Restrict", "Bounds"],
[ "id", "variable", "label", "variableType",
"restrict", "bounds"]);
tableModel.setDataAsMapArray(data);
tableModel.setColumnEditable(1, true);
var table = new qx.ui.table.Table(tableModel).set({
decorator: null
})
win.add(table);
var tcm = table.getTableColumnModel();
}
}
});
I would like to instead take from a local JSON file:
http://n2.nabble.com/file/n4450668/data2.json data2.json
and do something like:
var url = "data/data2.json";
var dtaController = new qx.data.controller.Object();
var store = new qx.data.store.Json(url);
tableModel.setDataAsMapArray(store.getModel());
to initialize the table.
--
View this message in context:
http://n2.nabble.com/Loading-Table-from-local-JSON-File-tp4450668p4450668.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel