package com.client; import com.smartgwt.client.types.AutoFitWidthApproach; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.SelectionAppearance; import com.smartgwt.client.types.SelectionStyle; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.SectionStack; public class CustomeDataGrid extends SectionStack{ public CustomeDataGrid(){ this.addMember(getViewPanel()); } public Canvas getViewPanel() { final ListGrid countryGrid = new ListGrid(); countryGrid.setWidth100(); countryGrid.setHeight100(); setLeaveScrollbarGap(false); countryGrid.setBorder("double"); countryGrid.setAlternateRecordStyles(true); countryGrid.setShowAllRecords(true); countryGrid.setSelectionType(SelectionStyle.SIMPLE); countryGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX); countryGrid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH); ListGridField countryCodeField = new ListGridField("countryCode", "Code", 40); ListGridField nameField = new ListGridField("countryName", "Country"); ListGridField independenceField = new ListGridField("independence", "Nationhood Date", 200); independenceField.setType(ListGridFieldType.DATE); ListGridField populationField = new ListGridField("population", "Population"); populationField.setType(ListGridFieldType.INTEGER); ListGridField gdpField = new ListGridField("gdp", "GDP ($B)"); gdpField.setType(ListGridFieldType.FLOAT); countryGrid.setFields(new ListGridField[] {countryCodeField, nameField, independenceField, populationField, gdpField}); countryGrid.setCanResizeFields(true); countryGrid.setData(CountryData.getRecords()); return countryGrid; } }