Add the method of auto-filling some input boxes to the Form of EasyUi, easyuiform

Source: Internet
Author: User

Add the method of auto-filling some input boxes to the Form of EasyUi, easyuiform

According to the project requirements, some input boxes of Form are filled Based on the obtained data. However, the default EasyUI Form does not have this method, and only one input box can be directly assigned a value, therefore, the setValues of the Form object is added to implement the filling function based on the given Id. The Code is as follows:

$.extend($.fn.form.methods, {    setValues: function (myself, data) {        var form = $(myself);                var opts = $.data(form[0], "form").options;                var cols = "," + data.items + ",";        for (var name in data.row) {            if (cols.indexOf(name) >= 0) {                var val = data.row[name];                                form.find("[id=\"" + name + "\"]").textbox("setValue",val);            }        }                opts.onLoadSuccess.call(form, data);        form.form("validate");    }});
An example of the above Code is as follows:

Function reply () {var row = $ ('# feedbackGrid '). datagrid ('getselected'); if (row) {$ ('# feedbackdlg '). dialog ('open '). dialog ('settitle', 'feedback response'); var obj ={}; obj. row = row; obj. items = "nickName, userId"; $ ('# fm '). form ('setvalues', obj); url = 'feedback/reply ';}}
As described above, the parameters passed in the setValues method are divided into two elements: row, which contains the actual data object, and items, which contains the id of the HTML object to be filled, multiple IDs are separated by commas.




Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.