/* * Isomorphic SmartGWT web presentation layer * Copyright 2000 and beyond Isomorphic Software, Inc. * * OWNERSHIP NOTICE * Isomorphic Software owns and reserves all rights not expressly granted in this source code, * including all intellectual property rights to the structure, sequence, and format of this code * and to all designs, interfaces, algorithms, schema, protocols, and inventions expressed herein. * * If you have any questions, please email
. * * This entire comment must accompany any portion of Isomorphic Software source code that is * copied or moved from this file. */ package com.smartgwt.sample.showcase.client.dataintegration.java.sql; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.layout.VStack; import com.smartgwt.client.widgets.form.FilterBuilder; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.sample.showcase.client.PanelFactory; import com.smartgwt.sample.showcase.client.ShowcasePanel; import com.google.gwt.i18n.client.NumberFormat; public class ServerAdvancedFilteringSQLSample implements EntryPoint { public void onModuleLoad() { DataSource dataSource = DataSource.get("worldDS"); final FilterBuilder advancedFilter = new FilterBuilder(); advancedFilter.setDataSource(dataSource); final ListGrid countryGrid = new ListGrid(); countryGrid.setWidth(550); countryGrid.setHeight(300); countryGrid.setAlternateRecordStyles(true); countryGrid.setDataSource(dataSource); countryGrid.setAutoFetchData(true); ListGridField countryField = new ListGridField("countryName"); ListGridField continentField = new ListGridField("continent"); final NumberFormat nf = NumberFormat.getDecimalFormat(); ListGridField populationField = new ListGridField("population"); populationField.setCellFormatter(new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if(record == null) return null; return nf.format(((Number)value).doubleValue()); } }); ListGridField areaField = new ListGridField("area"); areaField.setCellFormatter(new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if(record == null) return null; return nf.format(((Number)value).doubleValue()); } }); ListGridField gdpField = new ListGridField("gdp"); gdpField.setCellFormatter(new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if(record == null) return null; return nf.format(((Number)value).doubleValue()); } }); ListGridField independenceField = new ListGridField("independence"); countryGrid.setFields(countryField, continentField, independenceField, populationField, areaField, gdpField, independenceField); IButton filterButton = new IButton("Filter"); filterButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { countryGrid.filterData(advancedFilter.getCriteria()); } }); VStack layout = new VStack(10); layout.addMember(advancedFilter); layout.addMember(filterButton); layout.addMember(countryGrid); layout.draw(); } }