JQuery Easyui Tree Using drag-and-drop error summary _jquery

Source: Internet
Author: User

I always fail when I use tree drag, and the console prints a lot of errors.

After tracing analysis, it is found that this is an error caused by a special configuration.

The original error code is as follows:

$ (' #tree '). Tree ({
//omit other
loadfilter:function (data, parent) {return
data.rows;
}
});

Since my background return value is not a direct fit for tree use, you need to remove rows from it so that you have this code.

The reason for the Easyui error is that when you drag, the Loadfilter method is still invoked in the drag method, as shown in the following figure code:

Easyui in the previous processing, data has been processed for arrays, so when the Loadfilter method is invoked, Because the returned data.rows is definitely undefined rather than an array, there will be a subsequent error in the data operation, causing the drag to fail, and the entire tree is having problems.

The solution is also simple, changing the Loadfilter method to fit the default:

Loadfilter:function (data, parent) {
if ($.isarray (data)) {return
data;
}
return data.rows;
}

The main thing is to judge if data is a number of groups to return directly, otherwise return to my own data.rows.

The above is a small set to introduce the jquery Easyui tree using drag and drop encountered errors summary, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.