EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: fausastu on September 12, 2016, 07:40:50 AM



Title: Forms defined from javascript [SOLVED]
Post by: fausastu on September 12, 2016, 07:40:50 AM
Hi guys.

There is a way to programatically define fields in a form?
(LIke columns in datagrid)

Thanks in advance


Title: Re: Forms defined from javascript
Post by: jarry on September 12, 2016, 07:48:05 PM
You can define your field options and then write some code to create the inputing components. Please refer to the code below:
Code:
var fields = [{
label: 'Name:',
type: 'textbox',
width: 300
},{
label: 'Subject:',
type: 'textbox',
width: 300
},{
label: 'Language:',
type: 'combobox',
width: 300
}];

for(var i=0; i<fields.length; i++){
var opts = fields[i];
var input = $('<input>').appendTo('#ff').wrap('<div class="row"></div>');
input[opts.type](opts);
}


Title: Re: Forms defined from javascript
Post by: fausastu on September 13, 2016, 07:46:28 AM
Thanks Jarry!

Nice, smart and clear solution.