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.
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);
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With