Hey,
> I'm working with qooxdoo 1.2.x. I'm using a qx.ui.form.List with a controller
> and a model created out of a json string.
> When my app starts, a request to the server is made to get this json string,
> the model is created and binded to the controller and everything is fine.
> however, I'd like to dynamically add elements to this model.
>
> I understand that a model that comes from
> var m = qx.data.marshal.Json.createModel(data)
> is an array of qooxdoo objects. is this correct?
No. A model can be an array but it depends on what your data is. In general,
the returned model has the same structure as the data you added. If it was an
array, it will return an array. If it was an object, it will return an object
and so on.
> Can't I simply do m.push(object of the same type here) ?
Thats exactly the way you would go. But the question is how to create the
object of the same type. For that, you need to know what data comes from the
server. Lest do a little example how it could look. Imagine your data from the
server has the following structure:
[
{"name": "a", "id" : "12"},
{"name": "b", "id" : "1"},
{"name": "c", "id" : "122"},
]
If thats the case, you can simply create a new entry with
var entry = qx.data.marshal.Json.createModel({name: "new name", id: "new id"});
That entry is now exactly what you are looking for to push to the model. The
controller and the binding will reflect those changes in the UI immediately.
I hope that helps a bit,
Martin
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel