javascriptmodelqooxdoo

How to create a custom Model in Qooxdoo? (for a list)


I'm trying to make my own model but I don't know how.

I've been looking at the ListControllerWithObjects demo but I can only see:

var person = new demobrowser.demo.data.model.Person(); 

but don't show where it comes from or how is made. So this tutorial is not useful.

Why I want a custom model? I want to have custom class just for the model, to know the structure and to put custom methods in it.

I have: [{a: 2, b: 4}, {a: 1, b: 9}];

And I want to put it on a list, but using this

var model = this._model = new qx.data.Array([{id: 1, name: "Victor"}]);    
this._listController = new qx.data.controller.List(model, this._list, 'name');

doesn't work. The real error is SingleValueBinding:

"Binding property " + propertyname + " of object " + source + " not possible: No event available. ";

It cannot find the event.

The error in the console:

Uncaught qx.core.AssertionError: error


Solution

  • The answer to the first question is here:

    https://github.com/qooxdoo/qxl.demobrowser/blob/master/source/class/qxl/demobrowser/demo/data/model/Person.js

    This file contains the definition of the missing Person class