Christian,
Thanks a lot for your extensive explanation! Things are much more
clear for me now. I understand that basically I need to do the
following:
1) to retrieve structured JSON data;
2) to "flatten" it into a qx.data.Array of qx.core.Object's (each of
them containing group reference);
3) to create and maintain an index (a simple JavaScript associative
array).
So two more questions now.
First is about JSON data retrieval. If not using qx.data.store.Json,
how do I retrieve JSON data in the most elegant and concise way? I
would prefer to avoid low-level messing with qx.io.request.Xhr. What
do you think about extending qx.data.store.Json to provide my own
logic for conversion of JSON into an array of qx objects?
The second question deals with indexed access to the model. If we
create a separate entity for index (like that "lookup" JavaScript
array in your example), we will have to maintain its integrity, like
indexing elements when they are added, and removing an index upon
element removal. I'm thinking about encapsulating this logic into the
model itself. Again, what do you think about extending qx.data.Array
with indexing facilities and some get(key) method? (or maybe creating
a mixin for that?)
Thank you!
Ripston
On 06.05.2013 at 10:05 PM, "Christian Hagendorn" wrote:Hi Ripston,
the virtual list can only work with an array of qx objects. So your
transfer
efficient data structure wouldn't work with the current list
implementation.
But I think there is no real runtime issue, because independent from
the
data structure you have to create one qx object for each list item.
An algorithm for your data structure have to iterate over all groups
and
persons O(g+p) to create the needed objects. So only when the numbers
of
groups and persons are nearly equals. The algorithm would be
inefficient,
but for this case also the data structure would inefficient.
The algorithm for a tuple based data structure would iterate over all
persons O(p). But generally the numbers of groups would be much
smaller and
using your data structure would be better.
I would implement an own algorithm to create the needed qx objects and
would
not use the q or something similar.
Just define a qx object with the needed properties (name, status,
group,
etc.) and iterate over the raw data. I think this is a good trade-off.
Now to the update issue. Due the array restriction from the virtual
list
there is no efficient algorithm to update the state. An idea to avoid
the
expensive search is to create something like an lookup table (a map
with the
unique name as key and the reference to the object as value).
Here a pseudocode example:
var model = new qx.data.Array();
var lookup = {};
for (var i = 0; i < roster.length; i++)
{
var group = roster[i];
for (var k = 0; k < group.members.length; k++)
{
var member = group.members[k];
var item = new my.Class(member.name, member.status, member.group);
model.push(item);
lookup[item.name] = item;
}
}
Cheers,
Chris
--
View this message in context:
http://qooxdoo.678.n2.nabble.com/Creating-grouped-list-from-group-structured-JSON-data-tp7583449p7583470.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel