Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Showing icons for boolean fields in ListGrid

    Hi Isomorphic,

    I have the (I think simple) requirement of displaying icons for boolean fields (like the flag-field in #grid_appearance_columnorder-sample, but with a "translator"/valueMap).

    My .ds.xml field is:
    Code:
    <field name="BLOCKSPLACE" type="boolean" sqlStorageStrategy="singleCharYN" />
    My ListGrid has this field:
    Code:
    blocksPlaceLGF = new ListGridFieldBlocksPlace("BLOCKSPLACE");
    ListGridFieldBlocksPlace.java is
    Code:
    import java.util.LinkedHashMap;
    
    import com.smartgwt.client.types.ListGridFieldType;
    import com.smartgwt.client.widgets.grid.ListGridField;
    
    public final class ListGridFieldBlocksPlace extends ListGridField {
    
    	public ListGridFieldBlocksPlace(final String name) {
    		super(name);
    		setType(ListGridFieldType.IMAGE);
    		setValueMap(getCostsInQueueValueMap());
    	}
    
    	public static LinkedHashMap<String, String> getCostsInQueueValueMap() {
    		LinkedHashMap<String, String> vM = new LinkedHashMap<String, String>();
    		vM.put("Y", "[SKIMIMG]/silk/cross.png");
    		vM.put("N", "");
    		return vM;
    	}
    
    //	public static LinkedHashMap<Boolean, String> getCostsInQueueValueMap() {
    //		LinkedHashMap<Boolean, String> vM = new LinkedHashMap<Boolean, String>();
    //		vM.put(true, "[SKIMIMG]/silk/cross.png");
    //		vM.put(false, "");
    //		return vM;
    //	}
    }
    Both shown approaches result in a client side exception.
    Code:
    16:57:57.376 [ERROR] [lms] 16:57:57.300:TMR7:WARN:Log:Uncaught JavaScript exception: TypeError: _1.lastIndexOf is not a function in http://localhost:8080/lms/lms/sc/modules/ISC_Core.js?isc_version=v9.1p_2014-11-05.js, line 744
    
    com.smartgwt.client.core.JsObject$SGWT_WARN: 16:57:57.300:TMR7:WARN:Log:Uncaught JavaScript exception: TypeError: _1.lastIndexOf is not a function in http://localhost:8080/lms/lms/sc/modules/ISC_Core.js?isc_version=v9.1p_2014-11-05.js, line 744
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:304)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
        at com.smartgwt.client.util.SC.logWarn(SC.java)
        at com.smartgwt.client.util.LogUtil.handleOnError(LogUtil.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
        at java.lang.Thread.run(Unknown Source)
    I'm using v9.1p_2014-11-05.
    What's the correct way to translate a known and limited list of values coming from my DS to icon-filenames?

    Thank you & Best regards,
    Blama

    #2
    Hello everyone,

    solution is to define the field as text:
    Code:
    <field name="BLOCKSPLACE" type="text" length="1" />
    and use the valueMap LinkedHashMap<String, String>.

    Best regards,
    Blama

    Comment

    Working...
    X