On Sat, Dec 4, 2010 at 14:16, Marco Pompili <[email protected]> wrote:
>
> Hi qooxdoers,
>
> I'm retreiving data in json format and i want to put that data in a
> Simple()
> data model with the method:
>
> var jsonData = response.getContent();
> setData( jsonData );
>
> The problem is that the Json data is an array of object and so the method
> doesn't work.
>
> I would like to add directly json data into the table without doing this:
>
> var rows = new qx.data.Array();
>
> for ( var i = 0; i < jsonData.length; i++ ) {
>
> var row = [
> jsonData[i].col1,
> jsonData[i].col2,
> jsonData[i].col3
> ];
>
> rows.push( row );
> }
>
> mytablemodel.setData( rows );
>
> I would like to avoid to select the data manualli for every object, because
> Json is an array of objects from what i've learned:
>
> [[object],[object],[object],[object]]
>
> I would like to convert the json data structure in arrays:
>
> [[array],[array],[array],[array]]
>
> so i can use it directly to set data in my table data model.
>
HI Marco,
Are you not in control of the data at the server side? The easiest thing to
do is to arrange to send the data from the server as an array of arrays,
instead of as an array of objects.
You do have an alternate means to accomplish this, however. In addition to
the setData() method in the table model, there is also a setDataAsMapArray()
which takes something either very like, or exactly what your server is
currently sending. In order to use this method, you must assign IDs to each
column so that it knows how to parse the map into the appropriate columns.
You assign IDs using the second parameter of setColumns(). The first
parameter, which you're already using, is the array of column names. The
second parameter is an array of column IDs which are the keys in the map
(col1, col2, etc. in your example).
One of those options should get you off and running.
Derrell
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel