Wednesday, December 1, 2010

SmartGWT Tips

I am new to SmartGWT and using LGPL version. I will share my tips and tricks and if you have any question, do post me. I will try to answer your questions.

Tip#1: Try to use setAutoHeight() and setAutoWidth() functions of any widget as far as possible, the reason is that these functions set the height and width of the widget according to widget's text and font size.

Tip#2: Use the above functions as the DynamicForm's size is set according to its items and if you use it HLayout, it will be automatically go to left aligned. Dont't set its width to 100%. If you set it 100%, DynamicForm will appear in the middle of the HLayout.


Tip#3: Don't mix GWT and SmartGWT widgets but we can do the following things:

- Never use GWT's containers like HorizontalPanel, VerticalPanel or HorizontalSplitPanel etc for containing SmartGWT widgets as SmartGWT widgets' appearance start disturbing and usually widget.setWidth("100%"); does not work. Instead use HLayout or VLayout.


Tip#4: If you want that application should be consistent in all browsers then first of all always test you application in Firefox, Internet Explorer and other browsers. Usually application works fine in all browsers except Internet Explorer because IE does not have backward compatibility that is why you will notice that application is working in IE6 but not in IE7 or IE8.
If i get height, width, margin or padding issues then i use to follow the following technique.


- public class CommonUtil {

public static native String getUserAgent() /*-{
return navigator.userAgent.toLowerCase();
}-*/;
}

if(CommonUtil.getUserAgent().contains("msie"))
  {
     widget.setHeight((Window.getClientHeight() - 96 ) + "px");
  } else {
     widget.setHeight((Window.getClientHeight() - 94 ) + "px");
  }


- DOM.setStyleAttribute(widget.getElement(), "margin", "2px 0px 0px 0px");

No comments:

Post a Comment