I need to use a common data structure to initialize several lists with the same data. Using the following mechanism the list remains blank with no errors. Is this the correct approach:
//during startup a JSON structure representing
//a grouplist is fetched and added to a dataCollection
SetHierarchy: function (text, xml, XmlHttpRequest) {
var _a = this;
try {
// HIERARCHY is a global
__HIERARCHY = new dhx.DataCollection({ datatype: "json" });
__HIERARCHY.parse(dhx.DataDriver.json.toObject(text, xml), "json");
} catch (e) {
_a.Error("SetHierarchy", e)
}
},
//elsewhere in the code
showFilterView: function () {
var _a = this;
try {
$$(_a.NAME + '_filterHierarchy').show({ type: "slide", subtype: "in" });
if(!_a.hierarchyBound) {
if( __HIERARCHY == null ) {
window.setTimeout(dhx.bind(_a.showFilterView,_a),500);
_a.logToConsole("showFilterView: Sleeping..");
return;
}
$$(_a.NAME + '_filterHierarchy').sync( __HIERARCHY.data );
_a.hierarchyBound = true;
}
Sorry, I did not pay attention to the “group” word in the question title.
sync() method can not be used for TreeStore components which is grouplist. Therefore, I would recommend to use parse method in this case:
var data = new dhx.DataCollection();
data.load("books_tree.xml","xml",function(){
var items = data.serialize();
$$("mylist1").parse(items);
$$("mylist2").parse(items);
});
If sync() is required, let me know - I’ll attach the solution.
When the second group list parses the DataCollection the second list is only partially populated. I would appreciate a solution to this issue either via the parse method or sync.