Announcement

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

    Filter Issue with Date/Datetime Field, BETWEEN operator, N minutes from now/ago or N hours from now/ago.

    Hi isomorphic,

    I am seeing an filter issue with Date/Datetime Field, BETWEEN operator, N minutes from now/ago or N hours from now/ago .

    Code levels used:
    SmartGwt Version: "v14.1p_2026-03-05/Pro Deployment"

    Here is the code and steps to reproduce it:
    Code:
    public class Sandbox1 implements EntryPoint {
    
    public void onModuleLoad() {
    
    RelativeDateItem rdItemProperties = new RelativeDateItem();
    
    rdItemProperties.setTimeUnitOptions(TimeUnit.MINUTE, TimeUnit.HOUR, TimeUnit.DAY, TimeUnit.WEEK);
    
    RelativeDateItem.setDefaultProperties(rdItemProperties);
    
    
    DataSourceDateTimeField datetimeField = new DataSourceDateTimeField("datetime_name", "DateTime Field");
    
    datetimeField.setAttribute("validOperators", new OperatorId[] { OperatorId.EQUALS, OperatorId.IBETWEEN_INCLUSIVE });
    
    DataSourceDateField dateField = new DataSourceDateField("date_name", "Date Field");
    
    dateField.setValidOperators(new OperatorId[] { OperatorId.EQUALS, OperatorId.IBETWEEN_INCLUSIVE });
    
    
    DataSource ds = new DataSource();
    
    ds.setFields(datetimeField, dateField);
    
    
    Layout filterLayout = new VLayout();
    
    FilterBuilder filterBuilder = new FilterBuilder();
    
    filterBuilder.setDataSource(ds);
    
    filterLayout.addMember(filterBuilder);
    
    
    Button displayButton = new Button("Display Criteria");
    
    displayButton.addClickHandler(event -> {
    
    AdvancedCriteria ac = filterBuilder.getCriteria();
    
    JSONEncoder encoder = new JSONEncoder();
    
    encoder.setDateFormat(JSONDateFormat.LOGICAL_DATE_CONSTRUCTOR);
    
    String criteria = encoder.encode(ac.getJsObj());
    
    SC.say(criteria);
    
    });
    
    
    Button setButton = new Button("Set Criteria");
    
    setButton.addClickHandler(event -> {
    
    AdvancedCriteria criteria = filterBuilder.getCriteria();
    
    filterBuilder.setCriteria(criteria);
    
    });
    
    
    filterLayout.addMember(displayButton);
    
    filterLayout.addMember(setButton);
    
    filterLayout.show();
    
    }
    }


    Set Up:

    The Display Criteria button shows the current criteria string in a pop up dialog.

    The Set Criteria button get the criteria from the FilterBuilder and set it back.

    Steps:

    Case 1: EQUALS operator - N minutes/hours from now/ago - No Issue

    Click Set Criteria. >>> filter stay the same.



    Case 2: BETWEEN operator - N days/weeks from now/ago - No Issue


    Click Set Criteria. >>> filter stay the same.



    Case 3: BETWEEN operator - N minutes/hours from now/ago - Issue


    Here's the internal string returned by Display Criteria


    Click Set Criteria.


    The filter is changed to selecting a particular datetime/date.
    The filter is initially selected to
    Field Operator Start Value End Value
    DateTime Field between (inclusive) 1 minutes ago 2 hours from now
    Date Field between (inclusive) 3 hours ago 4 minutes from now
    After clicking the Set Criteria button, the selection is changed to:
    Field Operator Start Value End Value
    DateTime Field between (inclusive) 03/05/2026 14:29 03/05/2026 16:30
    Date Field between (inclusive) 03/05/2026 03/05/2026
    Code:
      AdvancedCriteria criteria = filterBuilder.getCriteria();
      filterBuilder.setCriteria(criteria);
    This is what the "Set Criteria" button does. I am trying to understand what causes the filter selection to change.


    Here's criteria string after Set Criteria.


    Last edited by stonebranch5; 6 Mar 2026, 10:58.

    #2
    Just to cover the basics:

    1) you need to test with the latest patched build (see smartclient.com/builds)

    2) you have not described what the issue is

    Comment


      #3
      I had hard time uploading images in the initial post. I have edited my post.

      Comment


        #4
        Hi there, after the edits, we have the same two issues:

        1) you need to test with the latest patched build (see smartclient.com/builds)

        2) you have not described what the issue is - it looks as if you still didn't upload images, and there's no text equivalent, so we can't tell what the issue is

        Just to emphasize, #1 is required. A test case that only works against a ~year old unpatched version is now a valid bug report.

        Comment


          #5
          Thank you. I have edited my post. I also tested with v14.1p_2026-03-05/Pro Deployment and saw the same behavior.

          Comment


            #6
            Thanks for the report. Indeed there was an issue with round-tripping RelativeDate criteria if the "offset" was in minutes or hours (no problems with dates).

            Fixed now for tomorrow's builds for all versions back to 12.1.

            Comment

            Working...
            X