Hello,
I played today little bit with DynamicForm and CanvasItem. I would like to build my own one to many and many to many component (ListGrid with Add, Remove button). I would like to react in my CanvasItem on data changes in DynamicForm. I’m not able to find any Handler or method (like setValues, …) which get ALWAYS invoked when data behind DynamicForm get changed. DynamicForm has many ways how to change data specially regarding ListGrid support like editSelectedData, setValues, editRecord. Have to I override all this methods in my own DynamicForm subclass and behave accordingly or is here some place where I can put my CanvasItem handling logic?
I was testing also VisualBuilder and support for one to many relations. We aren’t able to make correct DynamicForm which should handle such relations. Is here some sample or planned support for this kind of relations directly in VisualBuilder? For us it’s showstopper which inhibit usage of your other ways excellent product.
TNX also for previous help with my problems.
Pavel
Right override point for specifically what code? We can’t recommend override points in the abstract 
Note that a master-detail editor shouldn’t necessarily be a subclass of DynamicForm. It may compose multiple components.
If you build a master-detail component you’ll be able to add it to Visual Builder (see these docs from SmartClient) but it’s going to need to be authored in JavaScript, at least for now.
RE: CanvasItem and handling logic
For example when I click on row in master ListGrid component I execute in click event
updateForm.editSelectedData(listGrid);
where updateForm is DynamicForm containing CanvasItem. At this point I would like to fetch data and setup my components inside CanvasItem for example to show associated items. For now I have something like this:
final DynamicForm updateForm = new DynamicForm() {
public void editSelectedData(ListGrid selectionComponent) {
carsGrid.filterData(new Criteria("owner", selectionComponent.getSelectedRecord().getAttribute("id")));
super.editSelectedData(selectionComponent);
}
};
But this code is unflexible and doesn’t react to other forms of setting data to DynamicForm.
Best will be to have possibility to override setValue in CanvasItem where I can execute all necessary code (fetch rows, enable/disable buttons, …) and DynamicForm will ALWAYS set values through this setValue method. This way I should build reusable RelationItem inherited from CanvasItem. I understand that you have peers behind components which do real work. How we should make new composite components in SmartGWT?
You generally build composite components out of whatever superclass is closest in functionality (H/VLayout, Canvas, Window and SectionStack are common) and simply add children/members/items in the constructor.
You are probably better of starting from one of these than a form. Many, many DynamicForm APIs would need to be overridden to build a component where every single DynamicForm API made sense for your use case. Better to start with just the key APIs you want to expose and build from there.
RE: CanvasItem and handling logic
Yes but how should I get noticed that showed value is changed (for example click in master grid)? Have to I handle it in every place in master component?
Not following what the problem is.. you change the contents of the detail grid based on click on the master grid, right? Handle it there. If there’s more than one way to change which master record is selected, send both events through one function.
Just architecture cleanup
I was only asking if here is another way how to make some reusable component. Handling specific logic of one form item in every master component is not very clean from my point of view when other components can behave automatically. Thanks for your help.
I’m not sure why you think this would make the master component aware of the detail component (it doesn’t), but as soon as you dig into the details I’m sure you’ll figure it out. Good luck.