前台界面
<item id="customBarItem3" name="cmbSpeciality-item">
<xhtml:span id="cmbSpeciality" style="width:120px;"/> //必须是容器,而不是output
</item>
JS实现
mainActivity.mdDefaultLoad = function(event){
var sql = "select tx.* from ( select x.*,(select count(fid) from pmb_view_project where fparentid = x.fcode) as cnt "
+ "from pmb_view_project x ) tx where tx.fparentid ";
var dataMain = justep.xbl("dataMain");
if(!dataMain) return ;
pmcSystem.bindOutputAsComboBox("output3", "0=分部工程,1=子分部工程,2=分项工程", {disabled: true, border: false});
var element = pmcSystem
.generateTreeViewComboBox(
"",
{
tvDropBoardWidth : 400,
tvDropBoardHeight : 400,
tvMultiChoose : false,
tvLoadChildren : {
root : {
condition : "false",
dataModel : "/PMB/costManagement/data",
sql : (sql + "is null and tx.cnt>0"),
mapping : "fname=name,fcode=code,cnt,fPrjCatalogname=catalogname,fkind=kind",
name : "[this.name]",
value : "[this.code]",
hasChildren : "[CODE]pmcSystem.textAsInt('[this.cnt]', 0) > 0",
icon : "/UI/system/images/org/dept.gif"
},
c : {
condition : "true",
dataModel : "/PMB/costManagement/data",
sql : (sql + "='[this.code]'"),
mapping : "fname=name,fcode=code,cnt,fPrjCatalogname=catalogname,fkind=kind",
name : "[this.name]",
value : "[this.code]",
hasChildren : "[CODE]pmcSystem.textAsInt('[this.cnt]', 0) > 0",
icon : "/UI/system/images/org/dept.gif"
}
}
}, null, null, function(main, dropDown, input, option,
value, display, onGetValues, dataList) {
var fKind = onGetValues(function(node) {
return node.data.kind;
});
var kind = pmcSystem.textAsInt(fKind, 0);
if (kind == 0){
alert("请选择子节点");
return false;
}else{
return true;
}
}, function(main, dropDown, input, option, value, display,
onGetValues, dataList) {
var catalogname = onGetValues(function(node) {
return node.data.catalogname;
});
document.__special = {
id : value,
name : display,
cagname : catalogname
};
document.getElementById("projectSort").value = document.__special.cagname;
dataMain.setTreeRootFilter("PMB_WBSTree_Templ.fSpecialtyID='"+document.__special.id+"' and PMB_WBSTree_Templ.fParent IS NULL");
dataMain.refreshData();
});
var c = document.getElementById("cmbSpeciality");
if (c)
c.appendChild(element);
pmcSystem.removeToolbarItemEffect("tbsHeader", "cmbSpeciality-item");
};
