Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize rownumber column of smartgwt's Listgrid?

Tags:

java

gwt

smartgwt

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);
like image 913
corsair Avatar asked Jan 25 '13 16:01

corsair


1 Answers

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);
like image 142
enrybo Avatar answered Oct 15 '22 10:10

enrybo