如何使 GWT 列表框可编辑选择的一部分

发布于 2024-09-02 09:48:13 字数 169 浏览 7 评论 0原文

根据我的要求,我编写了一个自定义面板,它将显示三个列表框,使用户能够从此自定义列表框中选择日期。这三个列表框负责显示月、日、年值。现在我想让我的三个列表框可编辑并且同时可选择。我的意思是我想提供一个用户首选项,日期可以编辑,同时也可以选择。我怎样才能在 GWT 中做到这一点。这里我使用的是GWT2.0。任何人请给一个想法。

As per my requirement I have written a custom panel which will display three ListBoxes to enable user to select date from this custom list boxes.These three list boxes are responsible for showing month,day,year value. Now I would like to make my three list boxes are editable and at the same time selectable. I mean I would like to provide a user preferences that date can editable and at the same time selectable. How can I do this in GWT. Here I am using GWT2.0. Any one please give an idea.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你怎么这么可爱啊 2024-09-09 09:48:13

浏览器不提供这样的控件。 GWT 也没有。您需要编写自己的代码。 EXT-GWT(非免费)ComboBox 具有此功能。 http://www.extjs.com/examples/
Smart GWT 也是如此(也不是免费的) http://www.smartclient.com/smartgwt/ Showcase/#styled_combobox_category

如果您要自己推出,则可以从具有 TextBox 和单击 TextBox(或其一部分)时显示的 VerticalPanel 的 Composite 开始。您的面板将包含可点击的项目。

A browser does not provide such a control. Neither does GWT. You will need to code your own. EXT-GWT(not free) ComboBox has this functionality. http://www.extjs.com/examples/
So does Smart GWT (also not free) http://www.smartclient.com/smartgwt/showcase/#styled_combobox_category

If you were to roll your own, you would start with a Composite which has a TextBox and a VerticalPanel that is shown when a TextBox (or part of it) is clicked. Your panel would contain the clickable items.

心舞飞扬 2024-09-09 09:48:13

您可以使用 suggestBox 而不是列表框来解决这个问题。但用户必须开始输入才能显示列表。

You could work that out using a suggestBox instead of the list box. But user would have to start typing to display the list.

烟燃烟灭 2024-09-09 09:48:13

您可以使用绝对面板来实现相同的...
下面是代码片段。

使用文本框隐藏选择框调整文本框的宽度和位置,使其覆盖下拉列表...

final AbsolutePanel absolute_panel_edit_list = new AbsolutePanel();
final TextBox onhold_textbox = new TextBox();
final ListBox onhold = new ListBox();

for (int onholdcount = 0; onholdcount < onHoldTypes.length; onholdcount++)
{
   onhold.addItem(onHoldTypes[onholdcount]);
}

onhold.addKeyPressHandler(new KeyPressHandler()
{       
   @Override
   public void onKeyPress(KeyPressEvent event) 
   {
      onhold_textbox.setStyleName("onhold_textbox");
      absolute_panel_edit_list.add(onhold,0,8);
      absolute_panel_edit_list.add(onhold_textbox,1,10);
      absolute_panel_edit_list.setSize("142px", "35px");

      flex_row4.removeCell(4, 9);
      flex_row4.setWidget(4, 9, absolute_panel_edit_list);
      onhold_textbox.addMouseOutHandler(new MouseOutHandler() 
      {        
         @Override
         public void onMouseOut(MouseOutEvent event) 
         {
            String customized_time = onhold_textbox.getText();
            int no_of_elements = onhold.getItemCount();
            onhold.addItem(customized_time);
            onhold.setSelectedIndex(no_of_elements);
            flex_row4.removeCell(4, 9);
            flex_row4.setWidget(4, 9, onhold);
            flex_row4.setWidget(4, 11, completed_togglebutton);
            flex_row4.setWidget(4, 13, completed_label);      
         }
      });
   }
});

You can use absolute panel to achive the same ...
Below is the code snippet.

Hide the selectbox using textbox adjust the width and location of textbox so that it should cover dropdown list...

final AbsolutePanel absolute_panel_edit_list = new AbsolutePanel();
final TextBox onhold_textbox = new TextBox();
final ListBox onhold = new ListBox();

for (int onholdcount = 0; onholdcount < onHoldTypes.length; onholdcount++)
{
   onhold.addItem(onHoldTypes[onholdcount]);
}

onhold.addKeyPressHandler(new KeyPressHandler()
{       
   @Override
   public void onKeyPress(KeyPressEvent event) 
   {
      onhold_textbox.setStyleName("onhold_textbox");
      absolute_panel_edit_list.add(onhold,0,8);
      absolute_panel_edit_list.add(onhold_textbox,1,10);
      absolute_panel_edit_list.setSize("142px", "35px");

      flex_row4.removeCell(4, 9);
      flex_row4.setWidget(4, 9, absolute_panel_edit_list);
      onhold_textbox.addMouseOutHandler(new MouseOutHandler() 
      {        
         @Override
         public void onMouseOut(MouseOutEvent event) 
         {
            String customized_time = onhold_textbox.getText();
            int no_of_elements = onhold.getItemCount();
            onhold.addItem(customized_time);
            onhold.setSelectedIndex(no_of_elements);
            flex_row4.removeCell(4, 9);
            flex_row4.setWidget(4, 9, onhold);
            flex_row4.setWidget(4, 11, completed_togglebutton);
            flex_row4.setWidget(4, 13, completed_label);      
         }
      });
   }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文