[英]How to make datepicker cell editable?
I am using GWT datepicker cell in my celltable. 我在单元格表中使用GWT datepicker单元格。 Here onclick event and on enter event it popups datepicker and set the cell value to the date we have selected. 在这里,onclick事件和Enter事件会弹出datepicker并将单元格值设置为我们选择的日期。 Now i want to remove the selected date from cell and make the cell blank , any workaround for this? 现在,我想从单元格中删除选定的日期并使该单元格为空白,对此有任何解决方法?
Edit: 编辑:
public void onBrowserEvent(Context context, Element parent, Date value,
NativeEvent event, ValueUpdater<Date> valueUpdater) {
super.onBrowserEvent(context, parent, value, event, valueUpdater);
if ("click".equals(event.getType()))
{
valueUpdater.update(null);
}
}
From what I understand you want to delete a date from a table cell. 据我了解,您想从表格单元格中删除日期。
One way to do this is to modify the constructor of DatePickerCell
and to add a button that clears the date. 一种方法是修改DatePickerCell
的构造函数,并添加一个清除日期的按钮。
First copy com.google.gwt.cell.client.DatePickerCell
in your progect 首先在程序中复制com.google.gwt.cell.client.DatePickerCell
Unfortunately the editors can't be modified and you have to copy the editor. 不幸的是,编辑器无法修改,您必须复制该编辑器。 (All members are private) (所有成员均为私人)
HorizontalPanel horizontalPanel = new HorizontalPanel();
Button button = new Button("Clear");
button.addClickHandler(new ClickHandler()
{
//@Override
public void onClick(ClickEvent event)
{
// Remember the values before hiding the popup.
Element cellParent = lastParent;
Date oldValue = lastValue;
Object key = lastKey;
int index = lastIndex;
int column = lastColumn;
panel.hide();
// Update the cell and value updater.
Date date = null;
setViewData(key, date);
setValue(new Context(index, column, key), cellParent, oldValue);
if (valueUpdater != null) {
valueUpdater.update(date);
}
}
});
horizontalPanel.add(button);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.