是否可以从模型或extjs中的商店创建整个表单。我已经定义了模型和商店,但我不想再次定义所有字段来创建表单。
是否可以通过传递模型类或商店来创建表单?
答案 0 :(得分:0)
这是我根据GridPanel
的列配置渲染表单所做的事情。也许它可以让你知道从哪里开始。
renderContactFormFields: function (window) {
//In my case, the structure is such: Window->FormPanel->BasicForm->FieldSet
//So I want to add fields within the fieldset...
var fieldSet = window.down('form').down('fieldset');
var fieldSetItem;
//'fieldsToRender' is actually the 'columns' property of a GridPanel
//that I simply put into a property of the window object to access it later
for (var i = 0; i < window.fieldsToRender.length; i++) {
var col = window.fieldsToRender[i];
fieldSetItem = { name: col.dataIndex, fieldLabel: col.text };
//A textfield in this case, but you could have rules to change the type of field you want to render...
fieldSetItem.xtype = 'textfield';
fieldSet.add(fieldSetItem);
}
//finally, load the record within the form...(selectedContact is the record that was selected in the GridPanel...)
window.down('form').loadRecord(window.selectedContact);
}
所以你可以说是从模型中生成的,它与商店相关联,而商店又与GridPanel相关联。