Announcement

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

    Client Side DateTime Filter

    Using SmartGWT 2.4 LGPL, I am facing what I believe is a bug in the client-side filtering relating to Advanced Criteria.

    When updating a record, and using the ListGrid.updateData() method, the returned record is subject to client-side filtering. Normally, this is fine and works perfectly. However, when the Advanced Criteria contains DateTime fields, the filter fails.

    My isc console shows this as the debug info:
    Code:
    14:38:28.532:XRP5:DEBUG:ResultSet:isc_ResultSet_5 (created by: isc_ResultsPanel_1_0):row dropped:
    {id: "12",
    startTime: "2011-02-08 20:34:09.823 GMT+0000",
    name: "dpassen1"
    }
    didn't match filter: {operator: "and",
    criteria: Array[2],
    _constructor: "AdvancedCriteria"}
    14:38:28.533:XRP5:DEBUG:ResultSet:isc_ResultSet_5 (created by: isc_ResultsPanel_1_0):updated cache: 0 row(s) added, 0 row(s) updated, 1 row(s) removed.

    #2
    This isn't particularly meaningful since you're not showing the criteria.

    Comment


      #3
      My apologies. Could it be the difference in Time formats?
      Code:
         "params":{
              "operator":"and", 
              "criteria":[
                  {
                      "operator":"and", 
                      "criteria":[
                          {
                              "fieldName":"startTime", 
                              "operator":"greaterOrEqual", 
                              "value":"2011-02-01T05:00:00"
                          }
                      ]
                  }
              ], 
              "isc_metaDataPrefix":"_", 
              "isc_dataFormat":"json"
          },

      Comment


        #4
        Your record basically appears to contain a String, not a Date. This could be because of your "GMT+0000", which is not the expected timezone offset format.

        Comment


          #5
          What format is expected? I adjusted our server response to serialize dates as "yyyy-MM-dd'T'HH:mm:ss" to match the value found in the criteria, but the behavior is the same.

          I also verified that in the shared Datasource, used for the FilterBuilder and ListGrid, the date fields are of type DateTime.

          Comment


            #6
            That's the expected format, but if you apply those criteria to the shown record, you'll see that it works. Something else is wrong, so try creating a standalone test case.

            Comment


              #7
              I have narrowed down the cause of my problem.

              When the criteria includes a DateTime clause, it may be structured as a Relative Date Time
              Code:
              "criteria":[
              	{
              		"fieldName":"dateTime", 
              		"operator":"greaterOrEqual", 
              		"value":{
              			"_constructor":"RelativeDate", 
              			"value":"$today"
              		}
              	},
              or as an Absolute Date Time
              Code:
              "criteria":[
              {
              	"fieldName":"dateTime", 
              	"operator":"greaterOrEqual", 
              	"value":"2011-02-28T00:00:00"
              },
              The absolute works perfectly, the relative fails with the message:
              didn't match filter: {operator: "and",
              criteria: Array[2],
              _constructor: "AdvancedCriteria"}
              and the row disappears.

              Any help available would be appreciated.

              Comment


                #8
                That's interesting, but doesn't suggest a cause (since both formats work in automated tests). Can you create a standalone test case to demonstrate that there's really a framework issue here?

                Comment


                  #9
                  Here's the test I rigged up. Notice when using Relative Date Items such as Today and Yesterday, the status of the Records DOES NOT change. If you pick the actual dates corresponding to Today and Yesterday, they do.

                  Code:
                  package com.example.filtertest.client;
                  
                  import com.google.gwt.core.client.EntryPoint;
                  import com.smartgwt.client.data.DataSource;
                  import com.smartgwt.client.data.Record;
                  import com.smartgwt.client.widgets.IButton;
                  import com.smartgwt.client.widgets.events.ClickEvent;
                  import com.smartgwt.client.widgets.events.ClickHandler;
                  import com.smartgwt.client.widgets.form.FilterBuilder;
                  import com.smartgwt.client.widgets.grid.ListGrid;
                  import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
                  import com.smartgwt.client.widgets.grid.events.SelectionEvent;
                  import com.smartgwt.client.widgets.layout.VStack;
                  
                  public class FilterTest implements EntryPoint {
                  
                  	public void onModuleLoad() {
                  
                  		DataSource testDS = TestDataSource.getInstance();
                  
                  		final FilterBuilder filterBuilder = new FilterBuilder();
                  		filterBuilder.setDataSource(testDS);
                  
                  		final ListGrid entityGrid = new ListGrid();
                  		entityGrid.setWidth(550);
                  		entityGrid.setHeight(224);
                  		entityGrid.setDataSource(testDS);
                  		entityGrid.setAutoFetchData(true);
                  
                  		entityGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
                  			@Override
                  			public void onSelectionChanged(SelectionEvent event) {
                  				Record rec = event.getRecord();
                  				if (!event.getState() && rec != null) {
                  					rec.setAttribute("status", "read");
                  					entityGrid.updateData(rec);
                  				}
                  			}
                  		});
                  
                  		IButton filterButton = new IButton("Filter");
                  		filterButton.addClickHandler(new ClickHandler() {
                  			public void onClick(ClickEvent event) {
                  				entityGrid.filterData(filterBuilder.getCriteria());
                  			}
                  		});
                  
                  		VStack vStack = new VStack(10);
                  		vStack.addMember(filterBuilder);
                  		vStack.addMember(filterButton);
                  		vStack.addMember(entityGrid);
                  	
                  		vStack.draw();
                  	}
                  
                  }
                  Code:
                  package com.example.filtertest.client;
                  
                  import com.smartgwt.client.data.DataSource;
                  import com.smartgwt.client.data.DataSourceField;
                  import com.smartgwt.client.data.fields.DataSourceDateTimeField;
                  import com.smartgwt.client.data.fields.DataSourceIntegerField;
                  import com.smartgwt.client.data.fields.DataSourceTextField;
                  
                  public class TestDataSource extends DataSource {
                  
                  	private static TestDataSource ds = null;
                  
                  	private TestDataSource(String id) {
                  		setID(id);
                  		setRecordXPath("/entities/entity");
                  
                  		DataSourceField idField = new DataSourceIntegerField("id", "ID");
                  		idField.setHidden(true);
                  		idField.setPrimaryKey(true);
                  
                  		DataSourceField nameField = new DataSourceTextField("name", "Name");
                  
                  		DataSourceField statusField = new DataSourceTextField("status", "Status");
                  		statusField.setValueMap("new", "read");
                  
                  		DataSourceField dateTimeField = new DataSourceDateTimeField("dateTime", "Date Time");
                  
                  		setFields(idField, nameField, statusField, dateTimeField);
                  
                  		setDataURL("/filterTest/data/entityData.xml");
                  		setClientOnly(true);
                  	}
                  
                  	public static TestDataSource getInstance() {
                  		if (ds == null) {
                  			ds = new TestDataSource("testDS");
                  		}
                  		return ds;
                  	}
                  }
                  Code:
                  	<entities>
                  		<entity>
                  			<id>1</id>
                  			<name>dpassen1</name>
                  			<dateTime>2011-02-28T03:00:00</dateTime>
                  			<status>new</status>
                  		</entity>
                  		<entity>
                  			<id>2</id>
                  			<name>isomorphic</name>
                  			<dateTime>2011-02-28T05:00:00</dateTime>
                  			<status>new</status>
                  		</entity>
                  		<entity>
                  			<id>3</id>
                  			<name>smart</name>
                  			<dateTime>2011-02-28T10:00:00</dateTime>
                  			<status>new</status>
                  		</entity>
                  	</entities>

                  Comment


                    #10
                    Is the problem just "today" and "yesterday"? Are you seeing the same behavior if the relative range is "last two weeks"?

                    Comment


                      #11
                      All the Relative Fields (N days/weeks/months ago/from now and the Current day of last week/month) exhibit this behavior. It looks to me like it's breaking the filtering. Sometimes, I have to refresh after a relative DateTime filter to see the filter work again.
                      Last edited by dpassen1; 1 Mar 2011, 05:33.

                      Comment


                        #12
                        Any updates? Thoughts?

                        Comment


                          #13
                          Just a quick update to let you know we're working on this - we'll let you know as soon as we have it resolved.

                          Comment


                            #14
                            Ok this issue should now be resolved - please try the next nightly build

                            Regards
                            Isomorphic Software

                            Comment

                            Working...
                            X