Announcement

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

    SimpleType.setValidOperators() not working as expected

    Hi,
    According to the docs for SimpleType:
    Code:
    setValidOperators
    
    public void setValidOperators(OperatorId... operators)
                           throws IllegalStateException
    
        Set of search operators valid for this type.
    
        If not specified, the inheritsFrom type's operators will be used, finally defaulting to the default operators for the basic types (eg integer).
    
        Parameters:
            operators - validOperators Default value is null 
        Throws:
            IllegalStateException - this property cannot be changed after the underlying component has been created
    Alhough, as in test case below and print screen attached, default validators are not replaced by supplied list.
    MichalG

    1.SmartClient Version: v8.3p_2013-02-26/LGPL Development Only (built 2013-02-26)

    2. Firefox 3.6.17

    3. -

    4. -

    5.

    6. sample code if applicable
    Code:
    package pl.com.tech4.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.user.client.DOM;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.DataSourceField;
    import com.smartgwt.client.data.SimpleType;
    import com.smartgwt.client.types.FieldType;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.util.KeyCallback;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.form.FilterBuilder;
    
    public class MainEntryPoint implements EntryPoint {
       
        public void onModuleLoad() {
    
            DOM.getElementById("loadingPicture").removeFromParent();
     
            if (!GWT.isScript()) {
                KeyIdentifier debugKey = new KeyIdentifier();
                debugKey.setCtrlKey(true);
                debugKey.setKeyName("Y");
                Page.registerKey(debugKey, new KeyCallback() {
    
                    public void execute(String keyName) {
                        SC.showConsole();
                    }
                });
            }
           
            layout();
        }
       
        private void layout() {
           
            SimpleType testSimpleType = new SimpleType("test", FieldType.TEXT);
            testSimpleType.setValidOperators(OperatorId.EQUALS, OperatorId.NOT_EQUAL);
            testSimpleType.register();
           
            DataSource ds = new DataSource();
            DataSourceField fieldA = new DataSourceField();
            fieldA.setName("fieldA");
            fieldA.setType(testSimpleType);
            ds.setFields(fieldA);
           
            FilterBuilder fb = new FilterBuilder();
            fb.setDataSource(ds);
           
            fb.draw();
        }
    }
    Attached Files

    #2
    Hi again,
    Is there any way to restrict operator list just to: EQUALS and NOT_EQUAL by creating new SimpleType for custom type?
    Thanks,
    MichalG

    Comment


      #3

      You can restrict using the below piece of logic
      OperatorId[] opArr = new OperatorId[]{OperatorId.BETWEEN_INCLUSIVE, OperatorId.EQUALS, OperatorId.LESS_THAN};
      ds.setTypeOperators(FieldType.DATE, opArr);
      filterBuilder.setDataSource(ds);

      Comment

      Working...
      X