Code for dynamically loading data from treepanel

Source: Internet
Author: User

Copy codeThe Code is as follows:
Var tree = new Ext. tree. TreePanel ({
Region: 'west ',
Title: 'site tree :',
Width: 200,
MinSize: 150,
MaxSize: 200,
IconCls: 'ux-auth-menu-header-icon ',
Split: true,
AutoScroll: true,
AutoHeight: false,
Collapsible: true,
RootVisable: false, // do not display the root node
Root: new Ext. tree. TreeNode ({
Id: 'root ',
Text: 'authorization ',
Draggable: false,
Expanded: true
}),
Loader: new Ext. tree. TreeLoader ({
DataUrl: 'treeUtil.html? Content. method = getAllMenuTreeNodes'
})
});
Public void getAllMenuTreeNodes (ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response ){
String systemId = request. getParameter ("node ");
String haveCheckBox = request. getParameter ("haveCheckBox ");
IMenuManager menuManager = this. getPkgServer (). getDriver (). getSystemManageServer (). getMenuManager ();
List <HashMap> nodes = new ArrayList <HashMap> ();
String parentNodeName = menuManager. getMenu (Long. parseLong (systemId). getName ();
List <Menu> menus = menuManager. getMenus ("em. parent_name = '" + parentNodeName + "'");
For (Menu menu: menus ){
HashMap <String, Object> hm = new HashMap <String, Object> ();
Hm. put ("id", menu. getId ());
Hm. put ("text", menu. getTitle ());
Hm. put ("iconCls", menu. getName ());
Nodes. add (hm );
}
JSONArray ary = new JSONArray (nodes );
WriteJson (response, ary. toString ());
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.