GXT NumberField 不可編輯 (GXT NumberField not editable)


問題描述

GXT NumberField 不可編輯 (GXT NumberField not editable)

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);

‑‑‑‑‑

參考解法

方法 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

方法 2:

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();
    }
  }

(by Yusuf K.Yusuf K.mmohab)

參考文件

  1. GXT NumberField not editable (CC BY‑SA 3.0/4.0)

#gwt #gxt






相關問題

通過 GWT-RPC 發送持久的 JDO 實例 (Sending persisted JDO instances over GWT-RPC)

GWT:帶有 db 變量的屬性文件的安全位置 (GWT: Safe place for properties file with db variables)

paket khusus dalam toples eksternal GWT (specific packages in a external jar GWT)

在 gwt 框架中使用參數更改 url (Changing url with parameters in gwt framework)

通過 JavaScript 在標題或 HTML 中動態包含腳本元素 (Dynamically include script element in header or HTML by JavaScript)

Java如何在構造函數中將接口作為參數傳遞? (Java How do I pass interface as parameter in Constructor?)

如何更改 gwt 面板的內容? (How to change the content of a gwt panel?)

內容類型是“應用程序/x-www-form-urlencoded”。預期的“文本/x-gwt-rpc” (Content-Type was 'application/x-www-form-urlencoded'. Expected 'text/x-gwt-rpc')

如何從谷歌應用引擎調用我的應用網址 (How to call my app url from google app engine)

GXT NumberField 不可編輯 (GXT NumberField not editable)

在碼頭上部署 gwt Web 應用程序 (deploying gwt web application on jetty)

在 gwt 中使用 html5 畫布畫一個圓圈? (draw a circle using html5 canvas in gwt?)







留言討論