Code:
Ext.Msg.alert("test", "test");
var formItems = new Ext.util.MixedCollection();
var items = [{
'name': 'source-type',
'ExtType': 'ComboBox'
}, {
'name': 'source-fileserver',
'ExtType': 'ComboBox'
}, {
'name': 'source-path',
'ExtType': 'Text'
}, {
'name': 'source',
'ExtType': 'Text'
}, {
'name': 'ensure',
'ExtType': 'ComboBox'
}];
Ext.each(items, function(item) {
var type = "Ext.form.field." + item['ExtType'];
if (item['name'] === 'source-type') {
newfield = Ext.create(type, {
xtype: "combo",
fieldLabel: "Source Type",
anchor: "100%",
MutuallyExclusive: "Content",
id: "field-Source-Type",
name: "source-type",
queryMode: "local",
store: [
"File Server",
"URI or absolute path"
],
typeAhead: true,
editable: false,
autoSelect: true,
selectOnFocus: true,
forceSelection: true,
ExtType: "ComboBox"
});
}
debugger;
if (item['name'] === 'source-fileserver') {
newfield = Ext.create(type, {
xtype: "combo",
fieldLabel: "Source",
anchor: "100%",
MutuallyExclusive: "Content",
id: "field-source-fileserver",
name: "source-fileserver",
queryMode: "remote",
displayField: "File",
store: [{
"File": "File Server"
}, {
"File": "URI or absolute path"
}],
typeAhead: true,
editable: false,
autoSelect: true,
selectOnFocus: true,
forceSelection: true,
ExtType: "ComboBox",
disabled: true
});
}
if (item['name'] === 'source-path') {
newfield = Ext.create(type, {
name: "source-path",
fieldLabel: "Source",
anchor: "100%",
id: "field-source-path",
xtype: "textfield",
nameField: true,
inputAttrTpl: " data-qtip='A valid URI or local\\remote absolute path or mapped drive'",
ExtType: "Text",
hidden: true
});
}
if (item['name'] === 'source') {
newfield = Ext.create(type, {
name: "source",
fieldLabel: "Source",
anchor: "100%",
id: "field-Source",
xtype: "textfield",
nameField: true,
inputAttrTpl: " data-qtip='A valid URI or local\\remote absolute path or mapped drive'",
ExtType: "Text",
hidden: true,
value: 'hello'
});
}
if (item['name'] === 'ensure') {
newfield = Ext.create(type, {
xtype: "combo",
fieldLabel: "Ensure",
id: "field-ComboEnsure",
name: "ensure",
inputAttrTpl: " data-qtip='File: Ensure the file exists with the given content/source. Directory: Ensure the folder exists with the provided source. Absent: Ensure the file/folder does not exist.'",
queryMode: "local",
displayField: "ensure",
valueField: "ensure",
store: [
"directory",
"file",
"absent"
],
typeAhead: true,
editable: false,
autoSelect: true,
selectOnFocus: true,
forceSelection: true,
ExtType: "ComboBox",
});
}
formItems.add(newfield);
});
Ext.Msg.alert("test3", "test3");
for (var i = 0; i < formItems.getCount(); i++) {
console.log('formItems.getAt(i):');
console.log(formItems.getAt(i));
console.log('formItems.getAt(i).getXType():');
console.log(formItems.getAt(i).getXType());
console.log('formItems.getAt(i).getValue():');
console.log(formItems.getAt(i).getValue()); // not working
console.log(Ext.getCmp(formItems.getAt(i)['id']).getValue()); // not working as well
}