sys:treeselect树图插件的使⽤
Html页⾯调⽤:
<div class="control-group">
<label class="control-label">事件源:</label>
<div class="controls">
<sys:treeselect id="eventSource" name="eventSource.id" value="${task.eventSource.id}" labelName="eventSource.name" labelValue="${task.eventSource.nam            title="事件源" url="/mes/wechat/mesEventSource/treeData" extId="${task.eventSource.id}" cssClass="required" notAllowSelectParent="true" allowClear="tr      <span class="help-inline"><font color="red">*</font></span>
</div>
</div>
js⾥⾯:
//Treeselect⾃定义回调函数,对应treeselect.tag的同名函数
function eventSourceTreeselectCallBack(eventSourceIds, eventSourceNames){
//根据事件源ID判断该事件是否为定时事件
$.ajax({
type:"POST",
url:"${ctx}/mes/wechat/mesEventSource/isTimer",
data:{"id" : eventSourceIds},
dataType: "json",
success:function(res){
if(res.isTimer==1){
//定时事件
$("#eventSourceCode input").de);
$("#name").val(eventSourceNames);  //当选择不同的事件源,任务名称也随之⽽变。默认任务名称和事件源名称相同。
}else{
//普通事件
$("#eventSourceName").val(""); //将事件源input框值清空
$("#eventSourceCode input").val("");
$("#name").val("");
msgx("只可添选定时事件,请重选!");
}
}
});
}
附录:sys:treeselect  控件代码
<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="id" type="java.lang.String" required="true" description="编号"%>
<%@ attribute name="name" type="java.lang.String" required="true" description="隐藏域名称(ID)"%>
<%@ attribute name="value" type="java.lang.String" required="true" description="隐藏域值(ID)"%>
<%@ attribute name="labelName" type="java.lang.String" required="true" description="输⼊框名称(Name)"%>
<%@ attribute name="labelValue" type="java.lang.String" required="true" description="输⼊框值(Name)"%>
<%@ attribute name="title" type="java.lang.String" required="true" description="选择框标题"%>
<%@ attribute name="url" type="java.lang.String" required="true" description="树结构数据地址"%>
<%@ attribute name="checked" type="java.lang.Boolean" required="false" description="是否显⽰复选框,如果不需要返回⽗节点,请设置notAllowSelectParent为tr <%@ attribute name="extId" type="java.lang.String" required="false" description="排除掉的编号(不能选择的编号)"%>
<%@ attribute name="isAll" type="java.lang.Boolean" required="false" description="是否列出全部数据,设置true则不进⾏数据权限过滤(⽬前仅对Office有效)"%> <%@ attribute name="notAllowSelectRoot" type="java.lang.Boolean" required="false" description="不允许选择根节点"%>
<%@ attribute name="notAllowSelectParent" type="java.lang.Boolean" required="false" description="不允许选择⽗节点"%>
<%@ attribute name="module" type="java.lang.String" required="false" description="过滤栏⽬模型(只显⽰指定模型,仅针对CMS的Category树)"%>
<%@ attribute name="selectScopeModule" type="java.lang.Boolean" required="false" description="
选择范围内的模型(控制不能选择公共模型,不能选择本栏⽬外<%@ attribute name="allowClear" type="java.lang.Boolean" required="false" description="是否允许清除"%>
<%@ attribute name="allowInput" type="java.lang.Boolean" required="false" description="⽂本框可填写"%>
<%@ attribute name="cssClass" type="java.lang.String" required="false" description="css样式"%>
<%@ attribute name="cssClass" type="java.lang.String" required="false" description="css样式"%>
<%@ attribute name="cssStyle" type="java.lang.String" required="false" description="css样式"%>
<%@ attribute name="smallBtn" type="java.lang.Boolean" required="false" description="缩⼩按钮显⽰"%>
<%@ attribute name="hideBtn" type="java.lang.Boolean" required="false" description="是否显⽰按钮"%>
<%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择,如果限制,设置为disabled"%>
<script type="text/javascript">
$("#${id}Button, #${id}Name").click(function(){
// 是否限制选择,如果限制,设置为disabled
if ($("#${id}Button").hasClass("disabled")){
return true;
}
// 正常打开
top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent(rquestUrl)+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}",  ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"确定":"ok", ${allowClear?"\"清除\":\"clear\", ":""}"关闭":true}, submit:function(v, h, f){
if (v=="ok"){
var tree = h.find("iframe")[0].;//h.find("iframe").contents();
var ids = [], names = [], nodes = [];
if ("${checked}" == "true"){
nodes = CheckedNodes(true);
}else{
nodes = SelectedNodes();
}
for(var i=0; i<nodes.length; i++) {//<c:if test="${checked && notAllowSelectParent}">
if (nodes[i].isParent){
continue; // 如果为复选框选择,则过滤掉⽗节点
}//</c:if><c:if test="${notAllowSelectRoot}">
if (nodes[i].level == 0){
top.$.jBox.tip("不能选择根节点("+nodes[i].name+")请重新选择。");
return false;
}//</c:if><c:if test="${notAllowSelectParent}">
if (nodes[i].isParent){
top.$.jBox.tip("不能选择⽗节点("+nodes[i].name+")请重新选择。");
return false;分页查询插件
}//</c:if><c:if test="${not empty module && selectScopeModule}">
if (nodes[i].module == ""){
top.$.jBox.tip("不能选择公共模型("+nodes[i].name+")请重新选择。");
return false;
}else if (nodes[i].module != "${module}"){
top.$.jBox.tip("不能选择当前栏⽬以外的栏⽬模型,请重新选择。");
return false;
}//</c:if>
ids.push(nodes[i].id);
names.push(nodes[i].name);//<c:if test="${!checked}">
break; // 如果为⾮复选框选择,则返回第⼀个选择  </c:if>
}
$("#${id}Id").val(ids.join(",").replace(/u_/ig,"")).change();
$("#${id}Name").val(names.join(","));
}//<c:if test="${allowClear}">
else if (v=="clear"){
$("#${id}Id").val("");
$("#${id}Name").val("");
}//</c:if>
if(typeof ${id}TreeselectCallBack == 'function'){
${id}TreeselectCallBack(v, h, f);
}
}, loaded:function(h){
$(".jbox-content", top.document).css("overflow-y","hidden");
}
});
});
</script>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。