Announcement

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

  • BUG REPORT: Values not showing on ListGrid FilterEditor after calling setCriteria(...)

    The code below shows issues on applying criterias to the grid using setCriteria(...). The filter value is not shown on the intField, but the contents of the grids are correctly filtered according to the established criteria.

    We encountered this bug using: Version v12.0p_2018-09-23/Enterprise Deployment (2018-09-23)

    Click image for larger version

Name:	grid_filter_bug.PNG
Views:	1
Size:	3.7 KB
ID:	256372

    Code:
    VLayout layout = new VLayout();
    RootPanel.get().add(layout);
    
    DataSource dataSource = new DataSource();
    dataSource.setClientOnly(true);
    dataSource.setTestData(RECORDS);
    DataSourceField sequenceField = new DataSourceSequenceField("id", "ID");
    sequenceField.setRequired(true);
    DataSourceField textField = new DataSourceTextField("textField", "Text Field");
    DataSourceField intField = new DataSourceIntegerField("intField", "Int Field");
    dataSource.setFields(sequenceField, textField, intField);
    
    
    ListGrid listGrid = new ListGrid(dataSource);
    listGrid.setSize("500", "200");
    listGrid.setCanEdit(true);
    listGrid.setAutoFetchData(true);
    listGrid.setShowFilterEditor(true);
    layout.addMember(listGrid);
    
    Criteria criteria = new AdvancedCriteria();
    criteria.addCriteria(new Criteria("intField", "42"));
    criteria.addCriteria(new Criteria("textField", "filter_value"));

  • #2
    Hi pci-abarbaro,

    what happens if you use 42 instead of "42" (without the "") in the new Criteria()?.

    Best regards
    Blama

    Comment


    • #3
      This is a subtle bug in your code - the way youíve constructed your criteria (which is a bit awkward, as youíre mixing AdvancedCriteria and Criteria, but not specifying operators...) you end with mismatched operators between the default operator for the grid field and the criteria youíre supplying.

      At that point, the grid canít allow editing of the criteria as it would change the operator. But by design, the criteria is still enforced.

      Comment


      • #4
        Thank you for the clarification, the code below behaves correctly.

        The grid used to work correctly even with a mix of AdvancedCriteria and Criteria. It stopped working when we upgraded from SmartGWT 5 to 12.
        Can we expect you to fix the different behavior introduced in the upgrade or we will have to change our code?

        Code:
        Criteria criteria = new AdvancedCriteria();
        criteria.addCriteria(new AdvancedCriteria("intField", OperatorId.GREATER_OR_EQUAL, 42));
        criteria.addCriteria(new AdvancedCriteria("textField", OperatorId.EQUALS, "filter_value"));
        listGrid.setCriteria(criteria);

        Comment


        • #5
          There was a bug fix in this area to do with not correctly defaulting operators for the field type. That probably affected the codepath you were using. We will not be reversing the bug fix.

          Note that, at the time, there was no documentation stating what would happen with the odd construction method youíre using here, so you were relying on unspecified behavior; that will definitely create upgrade issues.

          Comment


          • #6
            Hi pci-abarbaro,

            I'd also write the line
            Code:
            Criteria criteria = new AdvancedCriteria();
            as
            Code:
            Criteria criteria = new AdvancedCriteria(OperatorId.AND);
            to be very clear about what you are doing.

            Your inner AdvancedCriteria I'd write as Criterion (just class name change).

            For both changes that's just the way I'd do it, I don't know if this is also the suggested way of doing it.

            Best regards
            Blama

            Comment

            Working...
            X