How to resize a column column of a smartgwt Listgrid column?

Listgrid for smartgwt has a function to display the line number. I tried using this for small tables, and it works like a charm.

But for tables with more than 9999 rows, the row number column does not display more than four digits.

enter image description here

So here is the question. How to make Listgrid display all the digits in the 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);
+5
source share
1 answer

Check this one . You can 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);
+2
source

All Articles