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