Hello
Tell me how to count the number of leaves with userData at each level
By analogy treex.setChildCalcMode (“leafsrec”);
I corrected the code in a file dhtmlxtree.js.
When booting from the json, xml - OK, but tree.insertNewChild - until the problem. Know what to
change something in dhtmlXTreeObject.prototype._fixChildCountLabel.
dhtmlXTreeObject.prototype._getChildCounterValue = function (itemId) {
var temp = this._globalIdStorageFind (itemId);
if (! temp) return 0;
if ((temp.unParsed) | | ((! temp.XMLload) && (this.XMLsource)))
return temp._acc
switch (this.childCalc) {
case 1:
return temp.childsCount;
break;
case 2:
return this._getLeafCount (temp);
break;
case 3:
return temp._acc;
break;
case 4:
return temp._acc;
break;
case 5:
return temp._acc;
break;
}
};
dhtmlXTreeObject.prototype.setChildCalcMode = function (mode) {
switch (mode) {
case “child”:
this.childCalc = 1;
break;
case “leafs”:
this.childCalc = 2;
break;
case “childrec”:
this.childCalc = 3;
break;
case “leafsrec”:
this.childCalc = 4;
break;
case “leafsdatarec”:
this.childCalc = 5;
break;
case “disabled”:
this.childCalc = null;
break;
default:
this.childCalc = 4;
}
};
dhtmlXTreeObject.prototype._redrawFrom = function (dhtmlObject, itemObject, start, visMode) {
if (! itemObject) {
var tempx = dhtmlObject._globalIdStorageFind (dhtmlObject.lastLoadedXMLId);
dhtmlObject.lastLoadedXMLId = -1;
if (! tempx) return 0;
} Else tempx = itemObject;
var acc = 0;
for (var i = (start? start - 1: 0); i <tempx.childsCount; i + +) {
if ((! this._branchUpdate) | | (this._getOpenState (tempx) == 1))
if ((! itemObject) | | (visMode == 1)) tempx.childNodes [i]. htmlNode.parentNode.parentNode.style.display = “”;
if (tempx.childNodes [i]. openMe == 1) {
this._openItem (tempx.childNodes [i]);
tempx.childNodes [i]. openMe = 0;
};
dhtmlObject._redrawFrom (dhtmlObject, tempx.childNodes [i]);
if (this.childCalc! = null) {
if ((tempx.childNodes [i]. unParsed) | | ((! tempx.childNodes [i]. XMLload) && (this.XMLsource))) {
if (tempx.childNodes [i]. _acc) tempx.childNodes [i]. span.innerHTML = tempx.childNodes [i]. label + this.htmlcA + tempx.childNodes [i]. _acc + this.htmlcB;
else
tempx.childNodes [i]. span.innerHTML = tempx.childNodes [i]. label;
};
if ((tempx.childNodes [i]. childNodes.length) && (this.childCalc)) {
if (this.childCalc == 1) {
tempx.childNodes [i]. span.innerHTML = tempx.childNodes [i]. label + this.htmlcA + tempx.childNodes [i]. childsCount + this.htmlcB;
};
if (this.childCalc == 2) {
var zCount = tempx.childNodes [i]. childsCount - (tempx.childNodes [i]. pureChilds | | 0);
if (zCount) tempx.childNodes [i]. span.innerHTML = tempx.childNodes [i]. label + this.htmlcA + zCount + this.htmlcB;
if (tempx.pureChilds) tempx.pureChilds + +;
else tempx.pureChilds = 1;
};
if (this.childCalc == 3) {
tempx.childNodes [i]. span.innerHTML = tempx.childNodes [i]. label + this.htmlcA + tempx.childNodes [i]. _acc + this.htmlcB;
};
if (this.childCalc == 4)
{
var zCount = tempx.childNodes [i]. _acc;
if (zCount) tempx.childNodes [i]. span.innerHTML = tempx.childNodes [i]. label + this.htmlcA + zCount + this.htmlcB;
}
if (this.childCalc == 5)
{
var zCount = tempx.childNodes [i]. _acc;
if (zCount) tempx.childNodes [i]. span.innerHTML = tempx.childNodes [i]. label + this.htmlcA + zCount + this.htmlcB;
}
} Else if (this.childCalc == 4)
{
acc + +;
}
else if (this.childCalc == 5)
{
var check = 0;
for (var xi in tempx.childNodes [i]. userData)
{
if (tempx.childNodes [i]. userData [xi]. length! = 0)
{
check = 1;
break;
}
}
if (check> 0) acc + +;
/ / acc + +;
};
acc + = tempx.childNodes [i]. _acc;
if (this.childCalc == 3) {
acc + +;
}
}
};
if ((! tempx.unParsed) && ((tempx.XMLload) | | (! this.XMLsource)))
tempx._acc = acc;
dhtmlObject._correctLine (tempx);
dhtmlObject._correctPlus (tempx);
if ((this.childCalc) && (! itemObject)) dhtmlObject._fixChildCountLabel (tempx);
};