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.