GXT NumberField 不可编辑

发布于 2024-10-09 13:54:11 字数 205 浏览 0 评论 0原文

我正在使用 Gxt-2.2.0 和 GWT 2.0。并且 GXT Numberfileds 不可编辑。

对于可编辑的 NumberFields,我可以做什么?

下面的代码是没有希望的;

NumberField field = new NumberField();
field.setEditable(true);

I'm using Gxt-2.2.0 and GWT 2.0. And GXT Numberfileds is not editable.

What can I do for editable NumberFields?

Following code is hopeless;

NumberField field = new NumberField();
field.setEditable(true);

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

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

发布评论

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

评论(2

困倦 2024-10-16 13:54:11

我从 GXT 开发团队那里得到了答案。
简单的解决方案是将 Gxt-2.2.0 升级到 GXT-2.2.1。这次升级解决了这个问题。

来源

I take the answer from GXT Development Team.
The simple solution is upgrading Gxt-2.2.0 to GXT-2.2.1. This upgrade solved the problem.

Source

囚我心虐我身 2024-10-16 13:54:11

它是可编辑的,您的代码必须简单地工作,问题似乎与数字字段实现有关。

它只接受 0-9 之间的字符,似乎对于浏览器中的某些区域设置,它发送的是 0-9 以外的字符。你可以尝试其他浏览器(在我的例子中,它在 IE 中工作,而不是在 Firefox 中工作)

现在要解决你的问题,你必须通过调用来设置它接受的字符:

// They are by default 0-9 change them to your locale numbers
field.setBaseChars("0123456789");

如果你不知道区域设置数字字符是什么,你可以在 NumberField 类中的此方法中进行调试(检查关键变量):

protected void onKeyPress(FieldEvent fe) {
    super.onKeyPress(fe);
    char key = (char) fe.getKeyCode();
    if (fe.isSpecialKey(lastKeyCode) || lastKeyCode == KeyCodes.KEY_BACKSPACE
        || lastKeyCode == KeyCodes.KEY_DELETE || fe.isControlKey()) {
      return;
    }
    if (!allowed.contains(key)) {
      fe.stopEvent();
    }
  }

It's editable, your code must simply work, the problem seems with the number field implementation.

It accepts only characters from 0-9, seems for some locale setting in your browser, it's sending characters other than 0-9. you can try other browser (in my case it was working in IE and not in Firefox)

Now to solve your problem you have to set the characters it accepts by calling:

// They are by default 0-9 change them to your locale numbers
field.setBaseChars("0123456789");

if you don't know what are the locale number characters, you can debug in this method in the NumberField class (inspect key variable):

protected void onKeyPress(FieldEvent fe) {
    super.onKeyPress(fe);
    char key = (char) fe.getKeyCode();
    if (fe.isSpecialKey(lastKeyCode) || lastKeyCode == KeyCodes.KEY_BACKSPACE
        || lastKeyCode == KeyCodes.KEY_DELETE || fe.isControlKey()) {
      return;
    }
    if (!allowed.contains(key)) {
      fe.stopEvent();
    }
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文