See the docs for DataBoundComponent.fields. You can define fields on a component in addition to in the DataSource, and the are combined in a way that allows per-component customization.
Actually, I am using generic class which creates DynamicForm for me for any DataSource I provide at runtime. So, DS is only thing where I am doing specific things and rest of the code is generic so that I don't need to write same thing again for every form.
The approach I am following is working but only thing is that if section is closed (collapsed) then validations are not working and forms gets closed without saving anything.
Is this the side effect of the approach I am following.
This way I can use the same code for every form I create and I just need to set the datasource accordingly.
So, now I wanted to have sections in my form so I declared a type=section field in datasource itself and its showing sections as expected but if the sections are collapsed then validations don't work and saveData is called which is causing errors at server side in turn.
I want that if the sections are closed then also I should be able to validate fields in that collapsed section and if there are errors then section should expand to show inline field errors.
Please let me know if my requirement is not valid or I need to give some more code or explanation about requirement.
I have exactly the scenario as described in your documentation below - and I was wondering if there was an example list/form that you can point me to that show this in action? I have looked around but do luck. Thanks!
Whether to show fields of non-atomic types when a DataBoundComponent is given a DataSource but no component.fields.
If true, the component will show fields that declare a complex type, for example, a field 'shippingAddress' that declares type 'Address', where 'Address' is the ID of a DataSource that declares the fields of a shipping address (city, street name, etc).
Such fields may need custom formatters or editors in order to create a usable interface, for example, an Address field in a ListGrid might use a custom formatter to combine the relevant fields of an address into one column, and might use a pop-up dialog for editing.
--------
Try simply setting that attribute to true using any nested DataSources, for example, the ones in the Master-Detail Batch Load & Save example.
Thanks for that quick response. A small addition to the question - If I want to display the complex type in different sections in a Dynamic form, what's best way to do it? I am trying to use the following within the DataSource.ds.xml file, which creates the section, but I can't collapse it. My general question is, where is the master reference for all the possible <field> attributes? I couldn't find a description for type="Section" anywhere, except in this thread.
You specify a SectionItem by setting editorType:"SectionItem" - see the docs for this property.
Non-data fields like a section should not appear in the DataSource definition (this: what would a ListGrid do with it?). So you want a separate form definition that specifies sections. See the docs for useAllDataSourceFields in order to minimize duplication.
You specify a SectionItem by setting editorType:"SectionItem" - see the docs for this property.
Non-data fields like a section should not appear in the DataSource definition (this: what would a ListGrid do with it?). So you want a separate form definition that specifies sections. See the docs for useAllDataSourceFields in order to minimize duplication.
Thanks. Agreed with your MVC separation point. Though, the option of setting the editorType in the DataSource falls in the same breach, in my opinion. In any case, I added this to my DataSource to test it. I do see section headers with title "Section Header" with a "-" as prefix, implying that the sections are expanded. But I don't see any of the fields I'd expect to see under it. Meerly section headers that don't seem to do anything. Here's my Datasource -
Also, I am not clear as to what you mean by - you want a separate form definition that specifies sections - Are you suggesting to add the fields in the form one by one and explicitly putting them in sections? If so, that defeats what I am trying to achieve.
Presentation hints make sense in the DataSource when they are generic and do not apply only to a particular type of DataBoundComponent (eg SectionItem is specific to DynamicForm).
See SectionItem.itemIds, then see this discussion of DataBoundComponent.fields from the SmartClient docs - same concepts apply, we'll find a way to surface this doc within SmartGWT.
Presentation hints make sense in the DataSource when they are generic and do not apply only to a particular type of DataBoundComponent (eg SectionItem is specific to DynamicForm).
See SectionItem.itemIds, then see this discussion of DataBoundComponent.fields from the SmartClient docs - same concepts apply, we'll find a way to surface this doc within SmartGWT.
Thanks for your quick response. Appreciate it. I have read all the areas you have hilighted in your responses and tried to incorporate as much as possible - but it seems like (since the editorType="SectionItem" doesn't work and I still don't see a way to create a generic form) I am left with custom coding the view by manually creating the sections as needed.
??? those docs point out multiple ways to achieve what you want. Take another read. Follow the link to useAllDataSourceFields this time.
Unfortunately I don't see a way following the documentation. Unless you can show me to a specific code sample that does what I am trying to do, I am affraid but I am at a loss.
Comment