Easyui Treegrid Implementation Click parent node to load child node

Source: Internet
Author: User

Encounter problems in the project today, to implement Easyui Treegrid implementation click on parent node to load child nodes

The first reaction is to go to Baidu, Google a bit, found that the answer on the web is not lazy loading is the Onbeforeexpand call append method

I decided to use the second method, defining the Onbeforeexpand method of Treegrid, and calling the Appen method inside.

But when I was running excitedly, something went wrong,

Firefox appears too much recursion exception hint

On the internet to look at the cause of the problem, we all say is, illegal use of the JS keyword, but I read a few times the code did not see the keyword.

So open Firefox view request record, found that every time I click on the expansion node, Firefox will send two requests

I started it myself.

Request 1:localhost:8080/system/dept/list.do?system_id=0&pid=1

The other is

Request 2:localhost:8080/system/dept/list.do?system_id=0&pid=1&id=1

But I did not initiate a second request, Ah, I began to check the code, remove the request I initiated 1, the request 2 also exists, and the value of the ID as I clicked the node is different, and is the click of the node Idfileld, then I silently removed the Treegrid URL inside the PID parameters, Turn the ID into PID in the background (add the attribute ID in the Dept class, assign the PID to the ID in the controller)

Ok! Here I find that Easyui will automatically initiate a request to load a child node when clicked, which is characterized by adding ' idfield ' = ' * * * ' on the default URL

This is OK, there is no need to manually call append.

Easyui Treegrid Implementation Click parent node to load child 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.