`
bianxiaobin1991
  • 浏览: 19607 次
社区版块
存档分类
最新评论

ExtJs单宗行tree

阅读更多
前台JS:
Ext.onReady(function(){
var root = new Ext.tree.AsyncTreeNode({
id : 'root',
text : '根节点',
loader : new Ext.tree.TreeLoader({dataUrl : 'servlet/basic'})
});
this.tree = new Ext.tree.TreePanel({
renderTo : 'hello',
root:root,
width : 1000
});

root.expand();
});
在前台,其中用到了this.tree一直不太明白this的作用域。如果使用var页面就显示这个变量没有用到
后台servlet:
List<Student> list = StudentService.getStudentList();
JSONArray array = new JSONArray();
JSONObject jsonObject;
for(Student stu : list){
jsonObject = new JSONObject();
jsonObject.accumulate("id", stu.getId());
jsonObject.accumulate("text", stu.getUname());
jsonObject.accumulate("leaf", true);
array.add(jsonObject);
}
String json = array.toString();
response.getWriter().print(json);
response.getWriter().flush();
循环节点应该在后台循环List集合,将集合单个值存入json中,供前台ExtJs解析
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics