/* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import com.smartgwt.client.data.Criterion; import com.smartgwt.client.data.DateRange; import com.smartgwt.client.data.RelativeDate; import com.smartgwt.client.types.TitleOrientation; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.events.DrawEvent; import com.smartgwt.client.widgets.events.DrawHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ButtonItem; import com.smartgwt.client.widgets.form.fields.DateRangeItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.sample.showcase.client.data.WorldXmlDS; import com.google.gwt.core.client.EntryPoint; public class GridDateRangeFilterSample implements EntryPoint { public void onModuleLoad() { VLayout layout = new VLayout(8); layout.setHeight100(); layout.setWidth100(); layout.setMembersMargin(10); // --------------------------------------------------------------------------------------- // Seperate DynamicForm Example (DateRangeItem) Label dateRangeLabel = new Label(); dateRangeLabel.setWidth(595); dateRangeLabel.setHeight(25); dateRangeLabel.setContents("External DynamicForm (DateRangeItem)"); dateRangeLabel.setBaseStyle("exampleSeparator"); DynamicForm form = new DynamicForm(); form.setWidth(500); form.setTitleOrientation(TitleOrientation.TOP); final DateRangeItem rangeItem = new DateRangeItem("independence"); rangeItem.setWidth("*"); rangeItem.setShowTitle(false); rangeItem.setAllowRelativeDates(true); DateRange dateRange = new DateRange(); dateRange.setRelativeStartDate(new RelativeDate("-1200m")); dateRange.setRelativeEndDate(new RelativeDate("-1000m")); rangeItem.setValue(dateRange); // Create a ListGrid displaying data from the worldDS final ListGrid grid1 = new ListGrid(); grid1.setWidth(595); grid1.setDataSource(WorldXmlDS.getInstance()); ButtonItem searchButtonItem = new ButtonItem("Filter"); searchButtonItem.setAutoFit(true); searchButtonItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { Criterion criteria = rangeItem.getCriterion(); grid1.fetchData(criteria); } }); form.setItems(rangeItem, searchButtonItem); // --------------------------------------------------------------------------------------- // Inline FilterEditor Example (MiniDateRangeItem) Label filterEditorLabel = new Label("FilterEditor (MiniDateRangeItem)"); filterEditorLabel.setWidth(595); filterEditorLabel.setBaseStyle("exampleSeparator"); filterEditorLabel.setHeight(25); // Create a ListGrid displaying data from the worldDS and also displaying a FilterEditor final ListGrid grid2 = new ListGrid(); grid2.setWidth(595); grid2.setDataSource(WorldXmlDS.getInstance()); grid2.setAutoFetchData(true); grid2.setShowFilterEditor(true); layout.setMembers(dateRangeLabel, form, grid1, filterEditorLabel, grid2); layout.addDrawHandler(new DrawHandler() { @Override public void onDraw(DrawEvent event) { Criterion criteria = rangeItem.getCriterion(); grid1.fetchData(criteria); } }); layout.draw(); } }