Easyui tree click the text to expand the node

Source: Internet
Author: User

When easyui expands the tree by default, it clicks the black triangle on the front of the node. In this way, operations are not human-friendly. In actual use, the presence of old computers and the vertigo of older users are often inaccurate; to expand a node by clicking the node name, you must add a method to expand the node to the expand event.

Add in onselect event

Certificate (this).tree('expand', node.tar get );

When the node is selected, expand the node under the node. This method only expands the next level node, and does not expand the nodes under the child node.

To expand all nodes:

Certificate (this).tree('expandall', node.tar get );

$(document).ready(function(){$('#dept').layout();$('#deptTree').tree({checkbox:false,url:'loadDeptJson.action?node=-1',onBeforeExpand:function(node,param){$('#deptTree').tree('options').url="loadDeptJson.action?node="+node.id;},onSelect:function(node){$('#deptContent').load("viewDepartment.action?department.id="+node.id);$(this).tree('expand',node.target);},});});

Bind multiple events to onclick. If a department has a person, the person is displayed in the grid. If a sub-department has a sub-department, the solution of the sub-department is displayed:
$ ("# Dept_tree"). Tree ({URL: "Servlet/searchservlet? Dispatch = 2 & unit_id = "+ unit_id +" & id = 0 ", // The URL here is the loading tree onbeforeexpand: function (node, Param) {$ ("# dept_tree "). tree ("options "). url = "Servlet/searchservlet? Dispatch = 2 & unit_id = "+ unit_id +" & id = "+ node. ID;}, onselect: function (node) {$ (this ). tree ("Expand", node.tar get); // expand the subnode of the clicked text },});
Onclick: function (node) {// alert ("ID" + node. ID + "department ID:" + node. attributes. department_id + "-- unit --" + node. attributes. unit_id); var url22 = "Servlet/searchservlet? Dispatch = 22 & unit_id = "+ node. attributes. unit_id; $. getjson (url22, {department_id: node. attributes. department_id}, function (data) {If (data. length = 0) {var url = "Servlet/searchservlet? Dispatch = 3 & department_id = "+ node. attributes. department_id; $ ("# person_grid "). dataGrid ({URL: URL, toolbar: results_grid_default_toolbar, columns: results_grid_default_columns })}});},



Easyui tree click the text to expand the node

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.