Announcement

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

    Limit filter operators shown when ListGrid.setShowFilterEditor(true)

    Hi Group,

    I would like to reduce the number of operators shown when right cliking on a ListGrid filter.
    E.g.

    supplyItemGrid.setShowFilterEditor(true);

    On a numeric column I want to limit the number of operators listed to:
    Equals
    Not Equals
    Less than
    Greated than.

    I want to remove (match case) and null operator. And provide user with more streamline set.

    Thanks

    #2
    The operators that appear can be controlled at various levels - see for example dataSourceField.validOperators.

    Comment


      #3
      I am using

      DataSourceFiled.setValidOperators(OperatorId.GREATER_OR_EQUAL, OperatorId.LESS_OR_EQUAL, OperatorId.IBETWEEN_INCLUSIVE, OperatorId.EQUALS);

      However "contains pattern" operator keeps showing up in the filter list of LOCALEINT column the ListGrid.

      I am using smartgwt-6.0p20160720. I downloaded the latest smartgwt 6.0p20170510 and try to change the AdaptiveFilterSample and it also auto adds "contains (default)"


      I would like to remove it. Is there a way?


      Comment


        #4
        Some months ago, this would have been the case - because we had logic that forcibly added contains/null/notNull to the list of available operators.

        However, that was fixed a while ago - and we're showing this working as expected in all cases in latest versions of 6.0 and 6.1.

        We'll need to see some runnable code that shows an issue - perhaps show the sample you mention with the changes you want to make.

        Comment


          #5
          Hi Isomorphic, thanks for your reply.

          This is from the ShowcaseEE

          AdaptiveFilterSample:

          DataSourceField iSKUDs = ds.getField("SKU");
          iSKUDs.setValidOperators(OperatorId.GREATER_OR_EQUAL, OperatorId.LESS_OR_EQUAL, OperatorId.IBETWEEN_INCLUSIVE, OperatorId.EQUALS);

          final ListGrid supplyItemGrid = new ListGrid();
          supplyItemGrid.setWidth(860);
          supplyItemGrid.setHeight(300);
          supplyItemGrid.setAutoFetchData(true);
          supplyItemGrid.setShowFilterEditor(true);


          supplyItemGrid.setFilterOnKeypress(true);
          supplyItemGrid.setFetchDelay(500);
          supplyItemGrid.setDataSource(ds);

          ListGridField skuField = new ListGridField("SKU", 64);
          TextItem mask= new TextItem();
          mask.setKeyPressFilter("[0-9,]");
          skuField.setFilterEditorProperties(mask);

          ListGridField nameField = new ListGridField("itemName", 192);
          ListGridField descriptionField = new ListGridField("description", 256);
          ListGridField categoryField = new ListGridField("category", 128);
          ListGridField unitsField = new ListGridField("units", 65);
          ListGridField costField = new ListGridField("unitCost", 65);

          supplyItemGrid.setFields(skuField, nameField, descriptionField, categoryField, unitsField, costField );

          canvas.addChild(supplyItemGrid);
          canvas.addChild(serverCountLabel);

          supplyItem.ds.xml:

          <DataSource
          ID="supplyItem"
          serverType="sql"
          tableName="supplyItem"
          titleField="itemName"
          testFileName="/ds/test_data/supplyItem.data.xml"
          dbImportFileName="/ds/test_data/supplyItemLarge.data.xml"
          >
          <fields>
          <field name="itemID" type="sequence" hidden="true" primaryKey="true"/>
          <field name="itemName" type="text" title="Item hello" length="128" required="true"/>
          <field name="SKU" type="localeint" title="SKU" length="10" required="true"/>


          I am running them via Eclipse Neon GWT Plugin and browsing with Google Chrome 57.0.2987.133 on Ubuntu.
          When I right click on SKU filter I get the setValidOperators(OperatorId.GREATER_OR_EQUAL, OperatorId.LESS_OR_EQUAL, OperatorId.IBETWEEN_INCLUSIVE, OperatorId.EQUALS);
          and "contains (default)" added as default on the operator list.

          thanks

          Comment


            #6
            The type is "localeInt", with a capital I in the middle

            Comment


              #7
              Oh yes, it works right on the sample.

              Thanks,
              Jessi
              Last edited by jessgarcia; 16 May 2017, 03:40.

              Comment


                #8
                Hi,

                I have a similar issue.

                In the project I'm working on we have a large search panel where the ListGrid does not have a bound DataSource.
                I seek to implement filter operators for one of the fields and since we do not have a DataSource I have run in to some problems.
                I am able to produce the filter operators for the field, but when the user switch between operators, the selected operator is not updated in the list. See below for an example where the symbol indicates that we have chosen "Between (inclusive)" (correct) but the list indicates "less than or equal too" (wrong) which is the default operator. How can I fix this? Am I perchance implementing the valid operators wrong since I do not use the dataSource?

                Click image for larger version  Name:	BugFilterOperatorPicker.PNG Views:	1 Size:	2.7 KB ID:	250411

                To accomplish this functionality I use a DataSource which has a DataSourceField to limit the available operators for the field in question.

                Code:
                        DataSource ds = new DataSource();
                        ds.setClientOnly(true);
                
                        DataSourceField wcuConnectionField = new DataSourceField(
                                VehiclesPanelColumn.WCU_CONNECTION_TIME.getAttribute(),
                                FieldType.INTEGER,
                                VehiclesPanelColumn.WCU_CONNECTION_TIME.getHeader());
                        wcuConnectionField.setValidOperators(
                                OperatorId.GREATER_OR_EQUAL,
                                OperatorId.LESS_OR_EQUAL,
                                OperatorId.IBETWEEN_INCLUSIVE);
                        ds.setFields(wcuConnectionField);
                
                        wcuTable.setDataSource(ds);
                For the field I specify that it can have filter operators:

                Code:
                        int start = 0;
                        for (VehiclesPanelColumn column : VehiclesPanelColumn.values()) {
                            ListGridField field = new ListGridField(column.getAttribute(), column.getHeader());
                            listgridFields[start++] = field;
                            .
                            .
                            .
                            if (column == VehiclesPanelColumn.WCU_CONNECTION_TIME) {
                                field.setType(ListGridFieldType.INTEGER);
                                field.setAllowFilterOperators(true);
                                field.setAlwaysShowOperatorIcon(true);
                                field.setFilterOperator(OperatorId.LESS_OR_EQUAL);
                            }
                            .
                            .
                            .
                         }
                        wcuTable.setFields(listgridFields);
                I am running smartgwt 6.1 and gwt 2.8.1.
                Last edited by HenrikAlk; 15 Nov 2017, 07:39.

                Comment


                  #9
                  We're not sure whether you have a DataSource or not here - first you say you don't, then you say you do and show code for configuring the DataSource ..?

                  First thing is to update to the latest patched version and see if this issue is still happening for you. If it is, work toward putting together a minimal, ready-to-run test case, to see if you can show that it's a framework issue.

                  Comment


                    #10
                    I understand your confusion. What I meant with that I do not use a DataSource is that I do not use a DataSource to populate the ListGrid with data. Rather I use ListGrid.setData(); to poluate the ListGrid with data.

                    I tried with the latest smartgwt version and I have the same issue there. Please see my independent window-class for an example of how to reproduce the issue:

                    Code:
                    public class ModalTestGrid extends Window {
                    
                        private static final String NAME_NAME = "name";
                        private static final String NAME_TITLE = "Name";
                        private static final String CONNECTED_NAME = "connected";
                        private static final String CONNECTED_TITLE = "Connected";
                        ListGrid testGrid = new ListGrid();
                        List<SomeClass> data = new ArrayList<>();
                        private int amountOfData;
                    
                        public ModalTestGrid() {
                            amountOfData = 20;
                            createData();
                            setupWindowSettings();
                            setupWindowStructure();
                        }
                    
                        private void createData() {
                            for(int i = 0; i < amountOfData; i++) {
                                data.add(new SomeClass("object_" + i, i));
                            }
                        }
                    
                        private void setupWindowSettings() {
                            setAutoSize(true);
                            setTitle("Test Grid");
                            setShowMinimizeButton(false);
                            setIsModal(true);
                            setShowModalMask(true);
                            setAutoCenter(true);
                        }
                    
                        private void setupWindowStructure() {
                            testGrid.setWidth(700);
                            testGrid.setHeight(500);
                    
                            DataSource ds = new DataSource();
                            ds.setClientOnly(true);
                    
                            DataSourceField wcuConnectionField = new DataSourceField(
                                    CONNECTED_NAME,
                                    FieldType.INTEGER,
                                    CONNECTED_TITLE);
                            wcuConnectionField.setType(FieldType.INTEGER);
                            wcuConnectionField.setValidOperators(
                                    OperatorId.GREATER_OR_EQUAL, 
                                    OperatorId.LESS_OR_EQUAL, 
                                    OperatorId.IBETWEEN_INCLUSIVE);
                    
                            ds.setFields(wcuConnectionField);
                            testGrid.setDataSource(ds);
                    
                            ListGridField nameField = new ListGridField(NAME_NAME, NAME_TITLE);
                            ListGridField connectedField = new ListGridField(CONNECTED_NAME, CONNECTED_TITLE);
                            connectedField.setAllowFilterOperators(true);
                            connectedField.setAlwaysShowOperatorIcon(true);
                            connectedField.setFilterOperator(OperatorId.GREATER_OR_EQUAL);
                            connectedField.setType(ListGridFieldType.INTEGER);
                    
                            testGrid.setFields(nameField, connectedField);
                            testGrid.setShowFilterEditor(true);
                    
                            RecordList testRecordList = new RecordList();
                            for(SomeClass object : data) {
                                Record record = new Record();
                                record.setAttribute(NAME_NAME, object.name);
                                record.setAttribute(CONNECTED_NAME, object.connected);
                                testRecordList.add(record);
                            }
                            testGrid.setData(testRecordList);
                    
                            addItem(testGrid);
                        }
                    
                        private class SomeClass {
                            public String name;
                            public int connected;
                    
                            public SomeClass(String name, int connected) {
                                this.name = name;
                                this.connected = connected;
                            }
                        }
                    }
                    Should I start a new thread for this?

                    Comment


                      #11
                      What specific version of SmartGWT did you try?

                      What steps are required in the UI to get the icon to show a different operator than is selected in the drop-down menu?

                      Comment


                        #12
                        I used the one available on your website: https://www.smartclient.com/product/download.jsp
                        I.e. version 6.1p originally released 2017-06-28.

                        To recreate the UI behavior I of course first draw an instance of ModalTestGrid. Then, I click the operator icon and change from the default operator to "less than or equal to". The icon updates correctly, but when I click the operator again, the default operator, "greater than or equal to", is still checked as chosen when it actually is the "less than or equal to" operator that has been chosen.
                        For this, I use Chrome version 62.0.3202.94 (Official version) (64 bit).

                        Can you recreate the behavior?

                        Comment


                          #13
                          We see the issue here and a fix has been added for builds dated November 23 and later.

                          Note that, once you update to the latest patched build from smartclient.com/builds, to pick up this fix, you will notice that your "between" option no longer appears in the operator menu - to get it back, just switch on ListGrid.allowFilterExpressions - this is required since there's no way to enter a pair of range values for a "between" without some kind of separator expression.
                          Last edited by Isomorphic; 21 Nov 2017, 23:37.

                          Comment


                            #14
                            Very good.

                            Thank you for your help.

                            Comment

                            Working...
                            X