Rusi Filipov schrieb:
> Hi everyone,
> 
> I'm new to qooxdoo and JavaScript and I want to implement a custom model 
> for my table. My table should display the properties of an object of a 
> given(known) class and should look like this:
> 
> Property | Value
> ---------+------
> prop1    | val1
> ---------+------
> prop2    | val2
> ---------+------
> prop3    | val3
> 
> The object looks like this:
> {prop1:"val1", prop2:"val2", prop3:"val3"}
> 
> The table should display the properties of any such object, so I thought 
> I could use a table model, that has a reference to the object and also 
> have a setter-Method to change that reference in the model.
> 
> MyModel {
> 
>    obj   // reference to the displayed object
> 
>    // some method that should be called by the table
>    // for displaying the data
>    getValueAt(row) {
>      switch (row) {
>        case 1: return obj.prop1;
>        case 2: return obj.prop2;
>        case 3: return obj.prop3;
>    }
> 
>    setObj(obj) {
>      this.obj = obj;
>      fireDataChanged();  // notify the table to update the data
>    }
> }
> 
> Is this a good approach to do this (it is used in Java Swing)?
> If yes, which methods of AbstractTableModel should I override or what 
> methods should I add? I'm not sure how my Model class should look like.

You have to override the abstract methods, the AbstractTableModel 
inherits from the TableModel. These are getRowCount, getValue and 
setValue (the last may be empty).

Take a look at the SimpleTableModel, it should be a good example for own 
table models.




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to