Announcement

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

    No time from DateTime fields in FilterBuilder

    Browser: FF 3.6.13
    SmartGWT: 2.2 and 2.4 (development snapshot Wed. Dec. 22)

    I'm using FilterBuilder to submit AdvancedCriteria to my rest data service. The data source for the filter builder uses DataSourceDateTimeFields but the time is not being included in the criteria submitted to the server.

    I've created a simple example that shows that the criteria generated does not included the time with the date (I was wondering if setting the editor was the problem so I tried with and without):
    Code:
    public class DateTest implements EntryPoint {
    	class MyDataSource extends DataSource {
    		public MyDataSource() {
    			
    			DataSourceDateTimeField dtf = new DataSourceDateTimeField("dtf", "DTF with editor");
    			DateTimeItem editor = new DateTimeItem();
    			editor.setUseTextField(true);
    			editor.setTextAlign(Alignment.LEFT);
    			dtf.setEditorType(editor);
    		
    			DataSourceDateTimeField dtf2 = new DataSourceDateTimeField("datef", "DTF no editor");
    			
    			setFields(dtf,dtf2);
    		}
    	}
    	public void onModuleLoad() {
    
    		final MyDataSource ds = new MyDataSource();
    		VLayout vl = new VLayout();
    		final FilterBuilder fb = new FilterBuilder();
    		fb.setDataSource(ds);
    		
    		IButton button = new IButton("Submit");
    		button.addClickHandler(new ClickHandler() {
    			public void onClick(ClickEvent event) {
    				ds.fetchData(fb.getCriteria());
    			}
    		});
    		vl.addMember(fb);
    		vl.addMember(button);
    		
    		vl.draw();
    	}
    }
    The console shows the following in the RPCRequest:
    Code:
       "params":{
            "_constructor":"AdvancedCriteria", 
            "operator":"and", 
            "criteria":[
                {
                    "fieldName":"dtf", 
                    "operator":"equals", 
                    "value":"2010-12-01"
                }, 
                {
                    "fieldName":"datef", 
                    "operator":"equals", 
                    "value":"2010-12-23"
                }
            ]
        },
    Having the time is critical for our use case. Is there something I missed or a workaround to get the time submitted?

    #2
    Thanks for the clear test case. This has been fixed and the fix will be present in tomorrow's nightly build.

    Comment


      #3
      Similiar issue with newest 3.0 and 2.5 nightly:

      Code:
      public class DateTest implements EntryPoint {
          class DateDataSource extends DataSource {
              public DateDataSource() {
      
                  DataSourceDateTimeField dtf = new DataSourceDateTimeField("datef", "DTF no editor");
                  
                  setFields(dtf);
              }
          }
          public void onModuleLoad() {
              
              DateUtil.setShortDatetimeDisplayFormat(DateDisplayFormat.TOEUROPEANSHORTDATETIME);
      
              final DateDataSource ds = new DateDataSource();
              VLayout vl = new VLayout();
              final FilterBuilder fb = new FilterBuilder();
              fb.setDataSource(ds);
              
              IButton button = new IButton("Submit");
              button.addClickHandler(new ClickHandler() {
                  public void onClick(ClickEvent event) {
                      ds.fetchData(fb.getCriteria(), new DSCallback() {
                          
                          @Override
                          public void execute(DSResponse response, Object rawData, DSRequest request) {
                              // TODO Auto-generated method stub
                              
                          }
                      });
                  }
              });
              vl.addMember(fb);
              vl.addMember(button);
              
              vl.draw();
          }
      }
      No time is being displayed in the datetime editor.
      With 2.5 nightly from 26.10.2011 this example works.

      Comment


        #4
        If you want filtering to be at the date and time granularity (not always desirable) use setEditorType() as with the previous sample.

        Comment


          #5
          The time is now displayed in the editor with setting:
          editor.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATETIME);

          BUT it always results in "xx.xx.xxx 12:00" no matter what time I enter in the text field. (SmartGWT 3.0 nightly 2012-01-12), so this doesn't work out either.

          Another point:
          Why isn't the setting:
          DateUtil.setShortDatetimeDisplayFormat(DateDisplayFormat.TOEUROPEANSHORTDATETIME);
          applied to the default DateTimeField editor?
          Last edited by megs; 16 Jan 2012, 05:14.

          Comment


            #6
            Formatters set what format is used if a datetime is displayed.

            The previous setting affects whether controls are shown for editing a datetime.

            Comment


              #7
              Thanks isomorphic.

              Could you please check on the "12:00" problem? See attached image.
              No matter what date + time I enter it results in a "12:00" validated time.

              Code:
              public class DateTest implements EntryPoint {
                  class DateDataSource extends DataSource {
                      public DateDataSource() {
              
                          DataSourceDateTimeField dtf = new DataSourceDateTimeField("dtf", "DTF with editor");
                          DateTimeItem editor = new DateTimeItem();
                          editor.setUseTextField(true);
                          editor.setTextAlign(Alignment.LEFT);
                          editor.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATETIME);
                          dtf.setEditorType(editor);
              
                          DataSourceDateTimeField dtf2 = new DataSourceDateTimeField("datef", "DTF no editor");
              
                          setFields(dtf, dtf2);
                      }
                  }
              
                  public void onModuleLoad() {
                      DateUtil.setShortDatetimeDisplayFormat(DateDisplayFormat.TOEUROPEANSHORTDATETIME);
              
                      final DateDataSource ds = new DateDataSource();
                      VLayout vl = new VLayout();
                      final FilterBuilder fb = new FilterBuilder();
                      fb.setDataSource(ds);
              
                      IButton button = new IButton("Submit");
                      button.addClickHandler(new ClickHandler() {
                          public void onClick(ClickEvent event) {
                              ds.fetchData(fb.getCriteria(), new DSCallback() {
              
                                  @Override
                                  public void execute(DSResponse response, Object rawData, DSRequest request) {
                                      // TODO Auto-generated method stub
              
                                  }
                              });
                          }
                      });
                      vl.addMember(fb);
                      vl.addMember(button);
              
                      vl.draw();
                  }
              }
              Attached Files

              Comment


                #8
                The "12:00" issue is still present in newest nightly of 3.0p (2012-01-23), cache cleared FF7, GoogleChrome 16.

                Setting DateFormatter "TOEUROPEANSHORTDATETIME" on a DataSoruceDatetimeField to display time now works correctly. So no need to manually set the editor as suggested.
                Thanks for that.

                Unfortunately any time entered still results in a time of "12:00".

                Cleaned and updated example code:
                Code:
                public class DateTest implements EntryPoint {
                    class DateDataSource extends DataSource {
                        public DateDataSource() {
                            DataSourceField idField = new DataSourceIntegerField("id", "ID");
                            idField.setHidden(true);
                            idField.setPrimaryKey(true);
                            
                            DataSourceDateTimeField dtf = new DataSourceDateTimeField("dtf", "DTF with editor");
                            DateTimeItem editor = new DateTimeItem();
                            editor.setUseTextField(true);
                            editor.setTextAlign(Alignment.LEFT);
                            editor.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATETIME);
                            dtf.setEditorType(editor);
                
                            DataSourceDateTimeField dtf2 = new DataSourceDateTimeField("datef", "DTF no editor");
                            dtf2.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATETIME);
                            
                            setFields(idField, dtf, dtf2);
                        }
                    }
                
                    public void onModuleLoad() {
                        DateUtil.setShortDatetimeDisplayFormat(DateDisplayFormat.TOEUROPEANSHORTDATETIME);
                
                        final DateDataSource ds = new DateDataSource();
                        VLayout vl = new VLayout();
                        final FilterBuilder fb = new FilterBuilder();
                        fb.setDataSource(ds);
                        
                        vl.addMember(fb);
                
                        vl.draw();
                    }
                }

                Comment


                  #9
                  Sorry, we mispoke, to specify what control is used for *filtering*, use setFilterEditorType(), not setEditorType().

                  Comment


                    #10
                    There is no setFilterEditorType option on a DataSourceField, only for trees and grids. But I want the setting to affect a FilterBuilder. (So only Datasource & FilterBuilder in example code)

                    The example provided just works fine (date & time entered in the form affect the result) with an older 2.5 build (2011-10-26). But not with newest 2.5 and 3.0, those always result in the entered date & time "12:00" as shown in the screenshot of my previous post (#7).

                    I really would like to use 3.0 because of the drawing features but for now this issue holds us back from upgrading.

                    Comment


                      #11
                      As of the next nightly build (3.0p branch, dated Feb 2 or greater), "editorType" will be respected for fields displayed in a FilterBuilder component.
                      So your code will show a DateTimeItem rather than a RelativeDateItem, which should get things working for you.

                      In terms of the time always showing as 12:00 on the RelativeDateItem hint text, this looks to be a real bug which has been assigned to one of our developers for further investigation. We'll update this thread when we have a resolution or more information on this.

                      Comment


                        #12
                        Your 12:00 issue ought to have been addressed in the next nightly build (2/7) - please let us know if you still see anything wrong.

                        Comment


                          #13
                          Did you apply the fix to 2.5p? If yes, when?

                          Using 2.5p (2012-04-03) we oberserve the same 12:00 behaviour.

                          Comment

                          Working...
                          X