Based on EasyUI, some input boxes in the Form are automatically filled. easyuiform

Source: Internet
Author: User

Based on EasyUI, some input boxes in the Form are automatically filled. easyuiform

Because the project needs to fill in some input boxes in the Form field of the dialog box based on the obtained data, and the default EasyUI does not support this method, 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");    }});

The above Code adds the setValues Method to the Form object of EasyUI. An example of calling 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 ';}}
When setValues is called, the input parameter contains two attributes: row, which is the actual data object, and items, which contains the ID of the input box to be filled, multiple IDs are separated by commas. This method fills all input boxes in items with the values in the row.




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.