简体   繁体   English

如何使日期选择器单元可编辑?

[英]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.

相关问题 GWT Celltable如何在“可编辑”列中制作不可编辑的单元格 - GWT Celltable How to make Non-Editable cell in Editable column 如何动态地使JTable单元可编辑/不可编辑? - How to make JTable cell editable/noneditable dynamically? 使用JButton使单元格可编辑 - Make cell editable with JButton 如何根据gxt中可编辑网格中的另一个单元格值使单元格不可编辑 - How to make cell as non editable based on another cell value in Editable Grid in gxt 如何使表视图的每个单元格在JavaFx中可编辑 - How to make each cell of table view Editable in JavaFx 如何让一个单元格表现得像它的可编辑但只读它? - How to make a cell behave like it's editable but have it read only? 如何在Java中的GlazedLists / JTable中使列,行或单元格可编辑? - How to make a column, row or cell editable in a GlazedLists/JTable in java? 如何使 JTable 单元格不可编辑但应该能够选择和复制当前单元格中的值 - how to make JTable cell non editable but should be able to select and copy the value in current cell 如何将可编辑内容转换为布尔值 - How to make an Editable into a Boolean 使JTable单元格编辑器值可选,但不可编辑? - Make JTable cell editor value be selectable, but not editable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM