Go Back   SmartClient Forums > Smart GWT Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 28th Mar 2010, 06:32
kieser kieser is offline
Registered Developer
 
Join Date: Aug 2009
Posts: 47
Default How to align buttons beneath a dynamic form (populated from datasource)

At the moment I am using trial and error with the cell borders set so that I can try to match two forms' widths to each other! There simply has to be a better of doing this.

What I have is a dynamic form populated from a data source. I set the datasource dynamically, so the form contents can change.

The form displays no problem. There are two columns, the left one being used for labels which smartGWT automatically populates and the right hand column is used for the data object. So far so good.

However, I need two buttons ("new" and "update") beneath the form. I want them to line up nicely beneath the data objects in the dynamic form.

So what I have done is create a second dynamic form and add the buttons to them. And by trial and error I am working out what the correct column widths should be. However, as smartGWT has complete control over the dynamic form that is populated from the datasource, what works for me in development right now may not work moving forward as datasources may change and smartGWT may choose to give different widths to the fields in the future.

So I want to be able to tell smartGWT to use the same widths for my buttons. But how to do this?

Here is my code:

Code:
	private static class CompoundEditor extends HLayout {  
		    private DataSource datasource, lookup;  
		    private DynamicForm form;  
.
.
.
		        form= new DynamicForm();
		        form.setDataSource(datasource);
.
.
.
		        saveButton = new ButtonItem("Update");  
		        saveButton.addClickHandler(new ClickHandler() {  
.
.
.
		        });  

		        newButton = new ButtonItem("New");
		        newButton.addClickHandler(new ClickHandler() {  
.
.
.
		        });  
		        editorLayout.addMember(form);

		        DynamicForm buttons = new DynamicForm();
		        buttons.setNumCols(4);
		        buttons.setColWidths("85","50","50","*");
		        
		        newButton.setStartRow(true);
		        newButton.setEndRow(false);
		        newButton.setColSpan(2);
		        newButton.setAlign(Alignment.RIGHT);

		        saveButton.setStartRow(false);
		        saveButton.setEndRow(true);
		        saveButton.setAlign(Alignment.RIGHT);

		        buttons.setFields(newButton,saveButton);
		        editorLayout.addMember(buttons);  
		        editorLayout.setWidth(280);
You can see that I have had to declare FOUR columns for the form that displays the buttons. This is because smartGWT places data objects onto the dynamic form that are actually not as wide as the column that it's placing them into. And this means that I cannot simply get the column widths of the dynamic form and use that. I have to try and match the placement of the data objects which are contained WITHIN the dynamic form right hand column.

This is what I am hoping to detect programmitically so that if smartGWT moves those data objects or resizes them, my buttons will adjust accordingly.
Reply With Quote
  #2  
Old 28th Mar 2010, 09:13
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,524
Default

It's not clear what appearance you want or what makes it difficult. A screenshot would probably help.
Reply With Quote
  #3  
Old 3rd Apr 2010, 23:11
ljw1001 ljw1001 is offline
Registered Developer
 
Join Date: Apr 2010
Posts: 6
Default Similar/same issue

I'm not exactly sure what the OP wants, but i thing it's similar to what I want. I've attached a screnshot. I have a two column form and want the two buttons to appear on the same row instead of one above the other.

Any help is much appreciated
Attached Images
File Type: gif capture.gif (4.9 KB, 327 views)
Reply With Quote
  #4  
Old 4th Apr 2010, 05:13
lazinskip lazinskip is offline
Registered Developer
 
Join Date: Dec 2008
Posts: 121
Default

ljw1001: You need to call setStartRow() and setEndRow() methods for ButtonItem variable with "false" argument
Reply With Quote
  #5  
Old 7th Apr 2010, 04:00
ljw1001 ljw1001 is offline
Registered Developer
 
Join Date: Apr 2010
Posts: 6
Default thanks!

worked perfectly.
Reply With Quote
  #6  
Old 22nd Jun 2011, 08:07
ducloi89 ducloi89 is offline
Registered Developer
 
Join Date: Jun 2011
Posts: 1
Default

thanks !!!
Reply With Quote
  #7  
Old 5th Oct 2012, 13:00
kyle.lix7 kyle.lix7 is offline
Registered Developer
 
Join Date: Jun 2012
Posts: 52
Default

Quote:
Originally Posted by lazinskip View Post
ljw1001: You need to call setStartRow() and setEndRow() methods for ButtonItem variable with "false" argument
Worked perfectly. Thanks!
Reply With Quote
  #8  
Old 5th Oct 2012, 17:46
amcculley amcculley is offline
Registered Developer
 
Join Date: Apr 2011
Posts: 258
Default

I have never used a ButtonItem in a form... I just use regular buttons in a layout. What is the advantage of using Buttons embedded in the form?
Reply With Quote
  #9  
Old 7th Oct 2012, 17:26
delshole delshole is offline
Registered Developer
 
Join Date: May 2012
Posts: 43
Default

Quote:
Originally Posted by amcculley View Post
I have never used a ButtonItem in a form... I just use regular buttons in a layout. What is the advantage of using Buttons embedded in the form?
Your buttons get laid out along with your other form items, instead of in a layout-controlled area by themselves.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved