Greg Dougherty
Greg Dougherty

Reputation: 3471

Making a "smart" DataSource for SmartGWT

I have a SmartGWT ListGrid that I want to make filterable and sortable. I have two columns, one with integer data, one with floating point data, where the user representation is textual rather than numeric. For example, I have a field holding directory sizes, with content like 10GB or 200 MB.

What I want to be able to do is (using a subclass of DataSourceIntegerField?) have a ListGrid with a column that displays the text version (i.e. 10 GB) but filters and sorts on the underlying (long) integer data (i.e. 10737418240). Is that possible with SmartGWT? If it is, is there any documentation I can read to show how it's done?

If it matters, my data is all ClientSide

Upvotes: 1

Views: 145

Answers (1)

Kanwaljeet Singh
Kanwaljeet Singh

Reputation: 1225

You can override the method ListGridField.setCellFormatter(), which takes an instance of CellFormatter(It is an interface, so you can create an anonymous class) and then override its format method. This way you can display the values in your own format. However you would still have to find a way to convert the underlying integer data to the correct value (i.e in GB or MB), once you get that just return value +"GB" or value+"MB" from format method.

You might want to look at the following link:-

http://www.smartclient.com/smartgwt/showcase/#grid_appearance_hilite_add

Upvotes: 1

Related Questions