Announcement

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

    MiniDateRangeItem refuses dates from DateTimeItem

    Firefox 24,
    <gwtVersion>2.6.1</gwtVersion>
    <smartgwtVersion>5.0-p20141210</smartgwtVersion>
    Isomorphic SmartClient/SmartGWT Framework (v10.0p_2015-11-20/Pro Deployment 2015-11-20)

    Hi,

    The problem we encounter cannot be reproduced on the showcase because it is probably due to a configuration issue.

    It occurs on a ListGrid where a "datetime" listGridField is defined (also tried without the cellFormatter).

    Code:
    final ListGridField receptionDate = new ListGridField("parent.creationDate", MESSAGES.receptionDate());
    receptionDate.setValueField("creationDate");
    receptionDate.setType(ListGridFieldType.DATETIME);
    receptionDate.setCellFormatter(new CellFormatter() {
                @Override
                public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                    if (value != null) {
                        return DateTimeFormat.getFormat("dd/MM/yyyy HH:mm:ss").format((Date) value);
                    }
    
                    return null;
                }
            });
    The listGrid has the setShowFilterEditor set to true and so, a MiniDateRangeItem is displayed to filter on this field.

    When we select relative dates, it works correctly.
    When we set the dateRange into the source code, it works correctly.
    But when we select dates through the DateTimeItem, the selected dates correctly appear into the dialog then disappear after clicking on the "OK" button.
    Moreover, it is not only a display problem because the criteria is not taken into account when filtering the data of the grid.

    There is no more configuration on this item in the view file and we have the same problem on each Date grid field.
    Do you have any idea to get the correct behavior for this item?

    Thanks

    #2
    The first problem we see is that your field name is invalid - "." is not a allowed.

    If that doesn't fix the problem, try replicating the issue by modifying a sample to introduce your formatting logic.

    Note also that you've reported two different versions for some reason (one from 2014 and one from 2015). You may somehow be mixing files from two different versions, which could create a lot of different problems.

    Comment


      #3
      Concerning the smartgwt version, it is due to a bad copy/paste from an other post I made, sorry. The version we are currently using is :

      <smartgwtVersion>5.0-p20151120</smartgwtVersion>

      Concerning the invalid name, this syntax is due to the data model behind this grid.
      We have two entities A and B, where B contains a reference to A, considered as its parent and named "parent". This parent is the one which has the "creationDate" attribute.
      Due to this nested structure, we linked the grid with a datasource that contains all our fields and the parent which refers to another datasource that only shows the creationDate.

      Code:
      <DataSource ID="A">
          <fields>
              <field primaryKey="true" name="id" type="integer" required="true" />
              <field name="parent" type="B" />
           ...
      
      <DataSource ID="B">
          <fields>
              <field primaryKey="true" name="id" type="integer" required="true"
                  hidden="true" />
              <field name="creationDate" type="datetime" />
          </fields>
      </DataSource>
      So using this name we can get the correct data from this complex structure.
      Nevertheless, there is another reason we need this kind of name. In fact, when we are filtering on our grid on server side, it's impossible for us to know where is creationDate if its path cannot be extracted from the name of the field.

      I hope with these informations you'll be able to better see the cause of our problem.
      On my side, i'll try to do the same in one of your samples.

      P.S. : I also have the same problem with classic fields without "." in their name and without any nested structure.
      Last edited by vlafon; 27 Jan 2016, 02:27.

      Comment


        #4
        If you are trying to retrieve something from a nested structure, there are several ways to do this depending on what kind of DataSource you are using server-side; take a look at dataSourceField.includeFrom and at dataSourceField.valueXPath, for example. And of course you can just define a field that has a CellFormatter that retrieves data from a subrecord.

        But what you definitely cannot do is continue to use that field name. Again, it is not supported, and if you look, you should fine warnings in the Developer Console telling you that it is not supported.

        Comment


          #5
          Hi,
          I finally had time to try the source code found in the showcase in our project.
          And it still does not work.
          Here are my classes but you will quickly see that it is really basic one :

          Code:
          public class TestFormViewImpl extends VLayout implements TestFormView {
          
              private final ListGrid grid;
          
              public TestFormViewImpl() {
                  DataSource dataSource = TestDataSource.getInstance();
          
                  this.grid = new ListGrid(dataSource);
                  this.grid.setAutoFetchData(true);
                  this.grid.setShowFilterEditor(true);
          
                  this.grid.setWidth100();
                  this.grid.setHeight100();
          
                  this.addMember(this.grid);
                  this.setWidth100();
                  this.setHeight100();
                  this.setMembersMargin(10);
              }
          }
          Code:
          public class TestDataSource extends DataSource {
              private static TestDataSource instance = null;
          
              public TestDataSource(String id) {
                  this.setID(id);
                  this.setDataURL("dataSource.xml");
                  this.setRecordXPath("/List/country");
          
                  DataSourceIntegerField idField = new DataSourceIntegerField("itemID");
                  idField.setHidden(true);
                  idField.setPrimaryKey(true);
          
                  DataSourceTextField itemNameField = new DataSourceTextField("textItem", "textItem", 128, true);
          
                  DataSourceDateField itemDateField = new DataSourceDateField("dateItem", "dateItem");
          
                  this.setFields(idField, itemNameField, itemDateField );
              }
          
              public static TestDataSource getInstance() {
                  if (instance == null) {
                      instance = new TestDataSource("testID");
                  }
                  return instance;
              }
          }
          datasource.xml :

          Code:
          <List>  
          <country>  
              <itemID>1</itemID>  
              <textItem>Bermuda1</textItem>
              <dateItem>1419-01-01</dateItem>
          </country>
          <country>  
              <itemID>2</itemID>  
              <textItem>Bermuda2</textItem>
              <dateItem>1419-01-02</dateItem>
          </country>
          <country>  
              <itemID>3</itemID>  
              <textItem>Bermuda3</textItem>
              <dateItem>1419-01-03</dateItem>
          </country>
          </List>
          It confirms that there is probably a bad configuration somewhere but I definitely don't know what it is.
          It seems that the value selected through the calendar of the MiniDateRangeItem is not understood as a valid Date and so is refused. Nevertheless, client-side validation doesn't show any error about the data entered and works correctly if I enter a bad value in the "From:" or "To:" fields.

          Can you give us some help about this?
          Thanks.

          Comment


            #6
            Your DataSource does not set dataFormat to "xml".

            If this doesn't fix the issue, please be specific about exactly what inputs you put into the MiniDateRangeItem UI and in what steps, and what the result is. Be sure to check the Developer Console for errors and warnings as well (always do this, and always report what's there, even if you just say "no errors or warnings").

            Finally, you're also using very old dates. Although this shouldn't be a problem, do you get the same issue if you use dates past 1970 (which would have positive Unix epoch time values)?

            Comment


              #7
              I reproduced the same code than the one in the SmartGwt showcase.

              http://www.smartclient.com/smartgwt/...ange_filtering

              There's no dataFormat specified in it, and it works with all kind of dates (obviously I tested it with more recent ones).
              The exact behavior is the same than the one specified in my first post :

              When we select relative dates, it works correctly.
              When we set the dateRange into the source code, it works correctly.
              But when we select dates through the DateTimeItem, the selected dates correctly appear into the dialog (and is well recognized as a date), but disappear after clicking on the "OK" button.

              Finally, there's no warning or error in the development console.

              Comment


                #8
                Not reproducing this. You keep providing very vague steps, please be specific.

                Please also test with at least two browsers and two different machines. You are now reporting an issue with really basic functionality shown in lots of samples - if it were really broken, we should have dozens of reports from other users.

                Comment


                  #9
                  Well I already tested it on several browsers and I always have the same result.

                  I can't really be more specific about the steps to reproduce it but definitly, I'm not saying it occurs in an empty project with just one ListGrid.
                  But in our project, we have this problem in a basic view so probably something in it has an impact on your widget behavior so it is unabled to understand DateRange filled through the DateTimeItem.

                  I'll give you some screenshots in my next post if you want more details, but the use of MiniDateRangeItem is quite obvious and there's no specific way to reproduce it : it just doesn't work with the DateTimeItem...

                  Comment


                    #10
                    I can't really be more specific about the steps to reproduce it but definitly..
                    Of course you can.

                    1. The sample you pointed to has two grids - which are you using?

                    2. Are you actually claiming you can reproduce a problem in the online version of the Showcase sample you pointed to? If so, list out the steps, including which specific dates you chose and what buttons you pressed.

                    3. What browsers are you testing? Include version and platform for at least 2.

                    4. Why do you keep talking about DateTimeItem? Neither your test case nor the sample you point to uses DateTimeItem

                    We don't need screenshots, we just need a way to reproduce the problem

                    Comment


                      #11
                      1. I am obviously talking about the second one, that has a similar source code than the one I showed you before.

                      2. As I said, it works correctly in the show case, there's no way to reproduce it out of our project. I don't expect you to reproduce it but to try to find ideas about what could break its behavior on our side. Even if it works in samples, I think it is not designed to be used only that way but inside real big projects like us.

                      3. I am testing it on Firefox 24.0, 44.0 and Chrome 48.0.2564.103 m.

                      4. The MiniDateRangeItem is in fact a widget that combines a DateRangeItem (the calendar button in the popup) and a RelativeDateItem (the two combo box From and To). So I am using this to be more precise about what doesn't work on our side in MiniDateRangeItem (even if maybe it is not called that way in it).
                      Last edited by vlafon; 11 Feb 2016, 07:22.

                      Comment


                        #12
                        4. The MiniDateRangeItem is in fact a widget that combines a DateRangeItem (the calendar button in the popup) and a RelativeDateItem (the two combo box From and To). So I am using this to be more precise about what doesn't work on our side in MiniDateRangeItem (even if maybe it is not called that way in it).
                        Yes, we're very aware that MiniDateRangeItem includes a DateRangeItem. Unfortunately, the widget you keep mentioning is DateTimeItem. So, are you saying that each time you mentioned DateTimeItem, you actually meant to say DateRangeItem?

                        It's good to get the clarification that you can't actually reproduce this anywhere but in your project. As far as it being reproducible only in your project, you probably have calls to DateUtil to change the global date and datetime formatters (eg setShortDateDisplayFormatter), but whatever format you have provided doesn't match the inputFormat (see setInputFormat()) or, your format may be strange enough that you need to install your own parser via setDateParser() (this would be unusual).

                        Comment


                          #13
                          Well, I must admit it's a little confused.
                          I give you a screenshot that shows the four step that illustrate our problem :
                          - 1st step : we open the MiniDateRangeItem
                          - 2nd step : we click on the calendar icon next to the "From" ComboBox, so a calendar widget appears to allow us to select an absolute date.
                          - 3rd step : we click on Apply and the date correctly appears in the combo box and next to the calendar icon. Then we repeat the step 2 and 3 for the "To" value.
                          - 4th step : we click on Ok. The filter is not applied in our grid.

                          I will try the idead you purposed.
                          Thanks.
                          Attached Files
                          Last edited by vlafon; 12 Feb 2016, 01:47.

                          Comment


                            #14
                            It's expected that the date filter criteria are not applied until you hit the funnel icon (far right of the Filter Editor row). We might revise this (it seems like it might as well filter right away) but the point is, up to these steps, you are at least seeing the same behavior everyone else is. So:

                            1. if you click the funnel icon, do you see the expected filtering?

                            2. previously you said the dates "disappear". So is that still happening, and if so, can you be specific about where they "disappear" from.

                            3. when you pick dates in the pop-up dialog and they appear in the ComboBox, how is the date formatted?

                            4. how are the dates formatted where there are shown to the right of the calendar icon?

                            Comment


                              #15
                              Well I added the screenshot to my previous post, I totally forgot it.
                              You will have all the answers of your questions in it.

                              The problem is anterior to the click on the funnel button. On step 4, in fact, the filter doesn't appear in the filter bar (it is still empty like before) and so a click on the funnel button has no effect.

                              As you said, we modify the dates format as following :

                              Code:
                              DateUtil.setNormalDateDisplayFormatter(DateUtil.TOEUROPEANSHORTDATE);
                              DateUtil.setNormalDatetimeDisplayFormatter(DateUtil.TOEUROPEANSHORTDATETIME);
                              DateUtil.setNormalTimeDisplayFormatter(DateUtil.TO24HOURTIME);
                              I'm gonna try to change the inputFormat of the MiniDateRangeItem to see if something changes.
                              Last edited by vlafon; 12 Feb 2016, 01:57.

                              Comment

                              Working...
                              X