How to resize rownumber column of smartgwt's Listgrid?
Asked Answered
P

1

6

Listgrid of smartgwt has a feature to show row number. I tried to use that for small tables and it works like a charm.

But for tables where the number of rows is more than 9999, "row number" column does not show more that 4 digits.

enter image description here

So, here is a question. How to make Listgrid to show all digits in "row number" column?

My test grid:

    ListGrid listGrid=new ListGrid();
    listGrid.setWidth(300);
    listGrid.setHeight(200);
    ListGridField name = new ListGridField("name", "Name");
    listGrid.setFields(name);
    listGrid.setShowRowNumbers(true);

    Record[] records=new Record[10000];
    for (int i=0; i<records.length; i++){
        Map<String, String> map=new HashMap<String, String>();
        map.put("name", "Hello");
        records[i]=new Record(map);
    }

    listGrid.setData(records);
    listGrid.setAutoFitData(Autofit.HORIZONTAL);
Pepsin answered 25/1, 2013 at 16:17 Comment(0)
M
2

Check this out. You'll be able to change the width.

The code should be something like

ListGridField rowNumberField = new ListGridField();

// Either
//-------------------------------------------------------
  rowNumberField.setWidth(15); //Whatever width you want
//-------------------------------------------------------
// Or
//-------------------------------------------------------
  rowNumberField.setAutoFitWidth(true);
//-------------------------------------------------------

ListGrid listGrid = new ListGrid();

listGrid.setRowNumberFieldProperties(rowNumberField);
Mignonmignonette answered 25/1, 2013 at 18:24 Comment(1)
setAutoFitWidth does not work for rowNumberField in my case, so I use setWidth approachPepsin

© 2022 - 2024 — McMap. All rights reserved.