Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How can I disable the Auto-Fit Feature of a Grid's Column

    Hi !

    I'm using the latest SmartGWT version.
    I built a Grid where one of the column contains icons. Text (an id) is on the left, while the icons are on the right of the column.
    My problem is that double-clicking on the column resizes it, without taking care that there are icons too. It only fits the text.

    I failed to find the setXXX to disable this behaviour.

    id.setWidth(120);
    id.setAutoFitWidth(false);
    id.setCanDragResize(false);

    Is not enough...

    What can I do ?

    thanks in advance !

    #2
    Hello,

    you could try:
    Code:
     listGridField.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
    so that field will resize to fit either the field title or the data values in the field.

    Else, you could disable the autofit operation for all fields of the listgrid,

    1) by overriding the onHeaderDoubleClick method:
    Code:
    listGrid.addHeaderDoubleClickHandler(new HeaderDoubleClickHandler() {
    	@Override
    	public void onHeaderDoubleClick(HeaderDoubleClickEvent event) {
    		// method stub
    	}
    });
    2) or by setting headerAutoFitEvent to AutoFitEvent.NONE so that no event will trigger auto-fit:
    Code:
    listGrid.setHeaderAutoFitEvent(AutoFitEvent.NONE);

    Comment


      #3
      If you only want to disable autofit on one column. You can setCanAutoFitFields(false); on the listgrid, then

      addHeaderDoubleClickHandler(new HeaderDoubleClickHandler()
      {
      public void onHeaderDoubleClick(HeaderDoubleClickEvent event)
      {
      if (event.getFieldNum()!=the_column_you_want_to_disable)
      autoFitField(getFieldName(event.getFieldNum()));
      }
      });

      You can also look into this thread for a solution to your original problems (but I feel it's too expensive having to do using cellformatter):
      http://forums.smartclient.com/showthread.php?t=15214

      Comment

      Working...
      X