How to adjust width of table row header column?


i have overridden the getItemIcon() of Table and set the rowHeaderMode to ROW_HEADER_MODE_ICON_ONLY.
This just runs fine, but: The column width is too large (34px). There is only a 16x16px icon in there so i want to set the width of the column to 18px.

How to do this?

I tried the following:

  1. CSS: No success - the whole table gets messed up if i adjust the row-header and content-header classes.
  2. CellStyleGenerator: The propertyId of the row header column is strangely NULL so i made:

       setCellStyleGenerator(new CellStyleGenerator() {			
			public String getStyle(Object itemId, Object propertyId) {				
				if (propertyId == null) {
					return "my-table-row-header";
				return null;

without success. This row header column is ignored somehow.

Any suggestions?


Did you try

setColumnWidth(null, 18);

Best Regards,

wow, that did it, thanks.

its a little bit uncommon to program against null :wink:
maybe the row header column should have a constant property id.

Actually, internally it has one: ROW_HEADER_FAKE_PROPERTY_ID

I can’t say right now why it’s not made available to the outside world (except for the naming…) It probably should.
Also, I seem to recall it’s been added as an afterthought - can you tell? :wink:

// Marc

i have seen the ROW_HEADER_FAKE_PROPERTY_ID but its assigned to new Object().

there is a magic conversion in some methods of Table like:

    public int getColumnWidth(Object propertyId) {
        if (propertyId == null) {
            // Since propertyId is null, this is the row header. Use the magic
            // id to retrieve the width of the row header.
            propertyId = ROW_HEADER_FAKE_PROPERTY_ID;

maybe this will be reworked someday :wink:

hi Marc

what does it mean
setColumnWidth(null, 18); i mean 18 value ??

Have you RTFJD? “Sets columns width (in pixels).”

Gotta fix the alignment for “setRowHeaderMode(Table.RowHeaderMode.INDEX)”, tho.
"setColumnAlignment(null, Table.Align.RIGHT); " doesn’t work.
C’mon, guys! Left aligned numbers?
.v-table-cell-content-rowheader {
text-align: right;