Hello,

In my app, there is a virtual tree which can be switched to connect to 
different datasources.

Rather than reload them any time the user switches between them, I would 
like to cache the tree node data on the client. Here is the code I use 
within a message subcriber function of the virtualtree:

var currentDatasource = this.getUserData('datasource');
var currentData  = this.getDataModel().getData();
var newDatasource   = message.getData();

// save tree node data to cache
if ( currentDatasource && currentData instanceof Array)
{
    // repair broken tree structure, this is necessary because some 
array elements are NULL
    for ( var i=0; i < currentData.length; i++)
    {
        if ( ! currentData[i] )
        {
            currentData[i]={ nodeId : i, children : [], label:"", 
bOpened:false, parentNodeId:0 };
        }
    }
    this.setUserData( "cache_" + currentDatasource, currentData );
}

// get tree node data from cache or from backend
var cacheNew = this.getUserData( "cache_" + newDatasource );
if ( cacheNew instanceof Array)
{
    this.getDataModel().setData(cacheNew);
}
else
{
    [ retrieve data from backend ]
}

But the data is stored correctly, but when it gets read from the cache 
and set to the data model, nothing happens. What could I do wrong?

Christian

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to