Announcement

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

    SelectItem and IN_SET operator

    Hello,
    I've found strange behaviour with SelectItem (multiple=true) used to filter data in ListGrid.
    When I use simple Criteria it work fine, but when I change to AdvancedCriteria I receive warnings:
    Code:
    MR9:WARN:DataSource:worldDS:Operator inSet is not valid for field continent. Continuing anyway.
    Why inSet operator is not valid to enum field with SelectItem?
    It was some time ago.

    Tested on SmartGWT 12.0p 2018-8-31

    Here is standalone test case with datasource from showcase:
    Code:
            ListGrid listGrid = new ListGrid();
            listGrid.setWidth100();
            listGrid.setHeight100();
            listGrid.setDataSource(WorldXmlDS.getInstance());
            listGrid.setShowFilterEditor(true);
            listGrid.setAutoFetchData(true);
    
            listGrid.setUseAllDataSourceFields(true);
    
            AdvancedCriteria criteria = new AdvancedCriteria();
            criteria.addCriteria("area", OperatorId.GREATER_THAN, "100");
    
            listGrid.setCriteria(criteria);
    
            ListGridField field = new ListGridField("continent", 120);
            field.setFilterOnKeypress(true);
    
            SelectItem filterStatus = new SelectItem();
            filterStatus.setMultiple(true);
            filterStatus.setOperator(OperatorId.IN_SET);
            field.setFilterEditorProperties(filterStatus);
    
            listGrid.setFields(field);
    
            this.addChild(listGrid);
    Best regards

    #2
    Does it work if you apply field.setFilterOperator(), rather than item.setOperator()?

    Comment


      #3
      In fact, you don't need to set the operator - the framework will automatically use inSet if multiple is true

      Comment


        #4
        It works but I still got warning.
        Warning disappears only when I manually add to datasourcefield setValidOperators(OperatorId.IN_SET);

        I've got another problem related.
        I've got a field with multiple tags and I want to filter with multiple values -> show records that have any given flag.
        Problem is when adaptive filter kicks in.
        Test case:
        Code:
        ListGrid listGrid = new ListGrid();
                listGrid.setWidth100();
                listGrid.setHeight100();
                listGrid.setDataSource(WorldXmlDS.getInstance());
                listGrid.setShowFilterEditor(true);
                listGrid.setAutoFetchData(true);
        
                listGrid.setUseAllDataSourceFields(true);
        
                AdvancedCriteria criteria = new AdvancedCriteria();
                criteria.addCriteria("area", OperatorId.GREATER_THAN, "100");
        
                listGrid.setCriteria(criteria);
        
                ListGridField field = new ListGridField("continent", 120);
                field.setFilterOnKeypress(true);
                field.setFilterOperator(OperatorId.IN_SET);
        
        //        SelectItem filterStatus = new SelectItem();
        //        filterStatus.setMultiple(true);
        //        filterStatus.setOperator(OperatorId.IN_SET);
        //        field.setFilterEditorProperties(filterStatus);
        
                ListGridField fieldTags = new ListGridField("tags");
                fieldTags.setFilterOnKeypress(true);
                fieldTags.setFilterOperator(OperatorId.IN_SET);
                fieldTags.setValueMap("tag1", "tag2", "tag3", "tag4");
        
                listGrid.setFields(field, fieldTags);
        
                this.addChild(listGrid);

        To the WorldXmlDS from Showcase added field:
        Code:
        DataSourceTextField fieldTags = new DataSourceTextField("tags");
                fieldTags.setMultiple(true);
                fieldTags.setMultipleValueSeparator(",");
        //        fieldTags.setValueMap("tag1", "tag2", "tag3", "tag4");
                fieldTags.setValidOperators(OperatorId.IN_SET);
        Sample data:
        Code:
        <country>
            <continent>North America</continent>
            <countryName>Bermuda</countryName>
            <countryCode>BD</countryCode>
            <area>50</area>
            <population>62099</population>
            <gdp>1700</gdp>
            <government>dependent territory of the UK</government>
            <capital>Hamilton</capital>
            <tags>tag1</tags>
        </country>
        <country>
            <continent>North America</continent>
            <countryName>United States</countryName>
            <countryCode>US</countryCode>
            <area>9372610</area>
            <population>266476278</population>
            <gdp>7247700</gdp>
            <independence>1776-07-04</independence>
            <government>federal republic</government>
            <capital>Washington</capital>
            <tags>tag1,tag2</tags>
        </country>
        <country>
            <continent>Europe</continent>
            <countryName>Monaco</countryName>
            <countryCode>MN</countryCode>
            <area>1.9</area>
            <population>31719</population>
            <gdp>788</gdp>
            <independence>1419-01-01</independence>
            <government>constitutional monarchy</government>
            <capital>Monaco</capital>
            <tags>tag2,tag3</tags>
        </country>
        What operator can be used to accomplish that??
        Best regards

        Comment

        Working...
        X