Hi. I want to create a date range filter for one of my fields in a ListGrid. Based on some other posts, it appears the recommended way is to create a FormItem and a FormItemIcon. I am having trouble getting the icon for the field to show up neatly -- it always shows up vertically offset by a few pixels, and I am trying to make it look just like a DateItem filter (perhaps without the textbox to freely enter a value).
If I set the icon up as a Picker, then the icon in the filter bar looks great, but it shows a picker window. If I remove the picker and use a FormItemIcon, then I have the offset problem that I can't seem to get around. Here is my code:
If I set the icon up as a Picker, then the icon in the filter bar looks great, but it shows a picker window. If I remove the picker and use a FormItemIcon, then I have the offset problem that I can't seem to get around. Here is my code:
Code:
public class DateRangeItem extends FormItem { private final ListGrid grid; public DateRangeItem(ListGrid listGrid) { super(); setTitle("Select Date Range"); this.grid = listGrid; addIconClickHandler(new IconClickHandler() { public void onIconClick(IconClickEvent event) { selectDate(); } }); FormItemIcon icon = new FormItemIcon(); icon.setPrompt("Select date range"); icon.setSrc("date_control.png"); setIcons(icon); setIconHeight(18); setIconWidth(18); setIconVAlign(VerticalAlignment.CENTER); // setPickerIconWidth(16); // setPickerIconHeight(16); // setPickerIconSrc("date_control.png"); // setShowPickerIcon(true); } public void selectDate() { DynamicForm form = new DynamicForm(); DateItem startDate = new DateItem("startDate"); startDate.setValue(new Date(System.currentTimeMillis() - ((long)1000 * 60 * 60 * 24 * 90))); // Default to 90 days prior DateItem endDate = new DateItem("endDate"); endDate.setValue(new Date()); ButtonItem filterButton = new ButtonItem("filter"); form.setItems(startDate, endDate, filterButton); Window popup = new Window(); popup.setWidth(500); popup.setHeight(300); popup.centerInPage(); popup.setIsModal(true); popup.addItem(form); popup.show(); } }
Comment