如何调整smartgwt的Listgrid的rownumber列的大小?

cor*_*air 5 java gwt smartgwt

smartgwt的Listgrid具有显示行号的功能.我尝试将它用于小桌子,它就像一个魅力.

但对于行数大于9999的表,"行号"列不会显示多于4个数字.

在此输入图像描述

所以,这是一个问题.如何使Listgrid显示"行号"列中的所有数字?

我的测试网格:

    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);
Run Code Online (Sandbox Code Playgroud)

enr*_*ybo 2

看一下这个。您将能够更改宽度。

代码应该是这样的

ListGridField rowNumberField = new ListGridField();

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

ListGrid listGrid = new ListGrid();

listGrid.setRowNumberFieldProperties(rowNumberField);
Run Code Online (Sandbox Code Playgroud)