加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

dojo Memory tree

发布时间:2020-12-16 21:37:03 所属栏目:百科 来源:网络整理
导读:jsp页面: div class="contentline listtree" div id="tree_container"#160;/div div id="div1"#160;/div /div script type="text/javascript" require(["dojo/request","dojo/dom","dojo/store/Memory","dijit/tree/ObjectStoreModel","dijit/Tree"],functi

jsp页面:

<div class="contentline listtree">
<div id="tree_container">&#160;</div>
<div id="div1">&#160;</div>
</div>

<script type="text/javascript">

require(["dojo/request","dojo/dom","dojo/store/Memory","dijit/tree/ObjectStoreModel","dijit/Tree"],function(request,dom,Memory,ObjectStoreModel,Tree){
request.get("http://localhost:8080/irmp-web/web/test/showAllFunction.htm",{
handleAs: "json"
}).then(function(data){
//alert(data);
var myStore = new Memory({
data:[{id: "root",children: data}],
getChildren: function(object){
return object.children;
}

});
var myModel = new ObjectStoreModel({
store: myStore,query: {id: 'root'},
mayHaveChildren: function(objectt){
//alert(objectt);
if(objectt.children.length>0){
return true;
}
return false;
}
});
var tree = new Tree({
model: myModel,
onClick: function(item){
var url = item["url"];
if(url != ""){
url = '${pageContext.request.contextPath}' + url + '?funcId=' + item["id"];
window.location.href = url;
}
},
showRoot:false
},dom.byId("div1"));
// tree.placeAt(win.body());
tree.startup();
});


});

</script>

TreeController类:

package com.ibm.banking.irmp.web; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import com.google.gson.ExclusionStrategy; import com.google.gson.FieldAttributes; import com.ibm.banking.auth.function.Function; import com.ibm.banking.auth.function.FunctionService; import com.ibm.banking.framework.web.view.GsonView; import com.ibm.banking.irmp.index.indicator.IndicatorService; @Controller @RequestMapping("/web/test") public class TreeController{ Logger log = LoggerFactory.getLogger(this.getClass()); @Autowired FunctionService functionService; @Autowired IndicatorService indicatorService; ExclusionStrategy exclusionStrategy = new ExclusionStrategy() { public boolean shouldSkipField(FieldAttributes field) { String fieldName = field.getName(); if (fieldName.equals("id") || fieldName.equals("name")|| fieldName.equals("children")|| fieldName.equals("url")) { return false; } return true; //return true; } public boolean shouldSkipClass(Class<?> clazz) { return false; } }; /** * 同步获取所有指标 ,使用异步获取指标的方式替代 * * @param request * @param model * @return */ @RequestMapping("/showAllFunction") public GsonView showAllFunction(Model model) { List<Function> funs = functionService.getFunctionTree(); model.addAttribute("funs",funs); //GsonView view = new GsonView("allcategories",null); GsonView view= new GsonView("funs",exclusionStrategy); return view; } }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读