DynamicForm form = new DynamicForm();
form.setWidth(500);
form.setHeight(22);
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);
form.setItems(rangeItem);
layout.addMember(form);
// Create a ListGrid displaying data from the worldDS
final ListGrid grid1 = new ListGrid();
grid1.setWidth(595);
grid1.setHeight(200);
grid1.setDataSource(WorldXmlDS.getInstance());
IButton searchButton = new IButton("Filter");
searchButton.setAutoFit(true);
searchButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Criterion criteria = rangeItem.getCriterion();
grid1.fetchData(criteria);
}
});
layout.addMember(searchButton);
layout.addMember(grid1);
// ---------------------------------------------------------------------------------------
// Inline FilterEditor Example (MiniDateRangeItem)
Label filterEditorLabel = new Label("FilterEditor (MiniDateRangeItem)");
filterEditorLabel.setWidth(595);
filterEditorLabel.setBaseStyle("exampleSeparator");
filterEditorLabel.setHeight(25);
layout.addMember(filterEditorLabel);
// Create a ListGrid displaying data from the worldDS and also displaying a FilterEditor
final ListGrid grid2 = new ListGrid();
grid2.setWidth(595);
grid2.setHeight(200);
grid2.setDataSource(WorldXmlDS.getInstance());
grid2.setAutoFetchData(true);
grid2.setShowFilterEditor(true);
layout.addMember(grid2);
layout.addDrawHandler(new DrawHandler() {
@Override
public void onDraw(DrawEvent event) {
Criterion criteria = rangeItem.getCriterion();
grid1.fetchData(criteria);
}
});
return layout;