Hello Community!
In my current work, users have to edit values in a ListGrid. The ListGrid has a ListGridEditorCostumizer that I've implemented by myself, because there are different editors needed for different values (ComboBoxes, CheckBoxes, etc.). In the case of the normal TextEditor (TextItem) there can be some values that users can include in the configured text as a placeholder.
For example:
The configured value in the ListGridField is "Hello", it could be needed to insert something between the two "l" (some standard value in my program (placeholder) that can be more than 50 characters long. The values are saved and needed in another program).
I checked the documentation and found the getSelectionRange() method. I tested it in an example dialog with just a DynamicForm and one TextItem. Everything works as it was expected. But in the case of the TextItem that is created in the getEditor() method of the ListGridEditorCosumizer, I get the JavaScript TypeError "undefined is not a function".
Here's some example code:
The codes creates a TextItem for the ListGridEditor. If you press ALT + "1", the variable "value" should contain everything until the beginning of the text selection + the string "_TEST_" + everything after the text selection. If nothing is selected the string "_TEST_" should just be added at the caret position.
I use
SmartGWT Version: 5.0
SmartClient Version: v10.0p_2014-11-16/LGPL Development Only (built 2014-11-16) (from Dev Console)
Browser:
Google Chrome 40.0.2214.111 m
StackTrace from Dev Console:
11:35:08.424:KUP0:WARN:Log:com.google.gwt.core.client.JavaScriptException: (TypeError)
__gwt$exception: <skipped>: undefined is not a function
at getSelectionRange(smarteai-0.js@20:64598)
at onKeyPress(smarteai-0.js@29:26451)
at $dispatch_23(smarteai-0.js@11:65509)
at dispatch_24(smarteai-0.js@43:65534)
at dispatch(smarteai-0.js@8:8601)
at dispatchEvent_0(smarteai-0.js@11:8832)
at $doFire(smarteai-0.js@9:8884)
at $fireEvent_1(smarteai-0.js@3:8927)
at $fireEvent_0(smarteai-0.js@29:8783)
at fireEvent_3(smarteai-0.js@47:38290)
at anonymous(smarteai-0.js@11:63961)
at apply_0(smarteai-0.js@23:4415)
at entry0(smarteai-0.js@16:4491)
at anonymous(smarteai-0.js@16:4465)
at obj.keyPress(smarteai-0.js@12:63968)
at isc_FormItem__fireKeyPressHandlers(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Forms.js@308:1129)
at isc_FormItem_handleKeyPress(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Forms.js@38:1125)
at isc_c_Class_invokeSuper(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@93:257)
at isc_c_Class_Super(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@170:249)
at isc_TextItem_handleKeyPress(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Forms.js@404:1480)
at isc_c_EventHandler_bubbleEvent(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@89:1535)
at isc_c_EventHandler_handleKeyPress(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@122:1319)
at isc_c_EventHandler__handleNativeKeyUp(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@78:1308)
at isc_c_EventHandler_dispatch(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@108:1610)
at eval(eval at isc__makeFunction (http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@122:55)
Thanks for your help!
improof
In my current work, users have to edit values in a ListGrid. The ListGrid has a ListGridEditorCostumizer that I've implemented by myself, because there are different editors needed for different values (ComboBoxes, CheckBoxes, etc.). In the case of the normal TextEditor (TextItem) there can be some values that users can include in the configured text as a placeholder.
For example:
The configured value in the ListGridField is "Hello", it could be needed to insert something between the two "l" (some standard value in my program (placeholder) that can be more than 50 characters long. The values are saved and needed in another program).
I checked the documentation and found the getSelectionRange() method. I tested it in an example dialog with just a DynamicForm and one TextItem. Everything works as it was expected. But in the case of the TextItem that is created in the getEditor() method of the ListGridEditorCosumizer, I get the JavaScript TypeError "undefined is not a function".
Here's some example code:
Code:
@Override
public FormItem getEditor(final ListGridEditorContext context)
{
final TextItem item = new TextItem();
item.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.isAltKeyDown()) {
String keyName = event.getKeyName();
if (keyName.equals("1")) {
int[] range = item.getSelectionRange();
int start = range[0];
int end = range[1];
String value = item.getValueAsString();
if (value == null)
value = "";
value = value.substring(0, start) + "_TEST_" + value.substring(end);
}
}
}
});
return item;
}I use
SmartGWT Version: 5.0
SmartClient Version: v10.0p_2014-11-16/LGPL Development Only (built 2014-11-16) (from Dev Console)
Browser:
Google Chrome 40.0.2214.111 m
StackTrace from Dev Console:
11:35:08.424:KUP0:WARN:Log:com.google.gwt.core.client.JavaScriptException: (TypeError)
__gwt$exception: <skipped>: undefined is not a function
at getSelectionRange(smarteai-0.js@20:64598)
at onKeyPress(smarteai-0.js@29:26451)
at $dispatch_23(smarteai-0.js@11:65509)
at dispatch_24(smarteai-0.js@43:65534)
at dispatch(smarteai-0.js@8:8601)
at dispatchEvent_0(smarteai-0.js@11:8832)
at $doFire(smarteai-0.js@9:8884)
at $fireEvent_1(smarteai-0.js@3:8927)
at $fireEvent_0(smarteai-0.js@29:8783)
at fireEvent_3(smarteai-0.js@47:38290)
at anonymous(smarteai-0.js@11:63961)
at apply_0(smarteai-0.js@23:4415)
at entry0(smarteai-0.js@16:4491)
at anonymous(smarteai-0.js@16:4465)
at obj.keyPress(smarteai-0.js@12:63968)
at isc_FormItem__fireKeyPressHandlers(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Forms.js@308:1129)
at isc_FormItem_handleKeyPress(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Forms.js@38:1125)
at isc_c_Class_invokeSuper(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@93:257)
at isc_c_Class_Super(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@170:249)
at isc_TextItem_handleKeyPress(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Forms.js@404:1480)
at isc_c_EventHandler_bubbleEvent(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@89:1535)
at isc_c_EventHandler_handleKeyPress(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@122:1319)
at isc_c_EventHandler__handleNativeKeyUp(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@78:1308)
at isc_c_EventHandler_dispatch(http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@108:1610)
at eval(eval at isc__makeFunction (http://localhost:8080/SmartEAI/smarteai/sc/modules/ISC_Core.js@122:55)
Thanks for your help!
improof