I have a formpanel as follows-
var theForm = new Ext.form.FormPanel({
layout: 'tableForm',
border: false,
itemId: 'theForm',
layoutConfig: { columns: 5 },
defaults: { border: false, layout: 'form' },
items: [
{ xtype: 'label', text: 'Row 1' },
{ xtype: 'label', text: '' },
{ xtype: 'label', text: '' },
{ xtype: 'label', text: '' },
{ xtype: 'label', text: '' },
{ xtype: 'label', text: 'Row 2' },
{ xtype: 'label', text: '' },
{ xtype: 'label', text: '' },
{ xtype: 'label', text: '' },
{ xtype: 'label', text: '' },
//.... And so on
]
})
This works well and adds rows to the panel. The empty label texts are generated on load. As you can see there can be 100s of rows with same layout(except col1) and I dont want to repeat this item layout 100 times.
Is there anything like adding controls by using loop or something. So that I dont have to repeat this. Is there any way so that I can add these 4 columns.
I tried using theForm.add({ xtype: 'label', text: '' });
but it is not working.
Well, what you have tried should work. I've never heard of a 'tableForm' layout though, maybe that's what breaks your form...
Here's an example that works (see this fiddle):
For cleaner code, you could also encapsulate that code by overridding the
initComponentmethod, that all Ext components inherit: