smartgwtrow-numberlistgrid

(Auto Fit All Columns) of ListGrid's Context Menu stretches the Row number in SmartGWT


I'm not sure whether this should be the expected behaviour or is a bug. When the Row Number column is set to be shown, selection of (Auto Fit All Columns) from context menu stretches the column to the end of the ListGrid.

I though there is an issue in our app but the ShowCase has (Grids > Appearance > Row Numbering) the same problem.

final ListGrid countryGrid = new ListGrid();  
countryGrid.setWidth(500);   
countryGrid.setHeight(224);  
countryGrid.setShowAllRecords(true);  
countryGrid.setShowRowNumbers(true);

If you change the width of a column before applying the Auto fit it behaves normally.

Has someone had the same issue ever?

Is there any workaround?


Solution

  • Without looking further at your code (for instance, other width and autofit related configurations applied to the list grid, field types and expected contents) it's difficult to know if this is expected behavior. Although I agree, by looking at the demo, that it is at least strange behavior.

    But this is what I do in my ListGrids to keep the row numbers at the size I want:

    // this field is created only as a way to define the row number field properties
    ListGridField rowNumberFieldProps = new ListGridField();
    rowNumberFieldProps.setWidth(50);
    rowNumberFieldProps.setCanAutoFitWidth(true);
    rowNumberFieldProps.setAutoFitWidthApproach(AutoFitWidthApproach.VALUE);
    grid.setRowNumberFieldProperties(rowNumberFieldProps);
    grid.setShowRowNumbers(true);
    

    Some notes: