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

    Date Chooser does not get the exact date selected in ListGrid Filter

    I am using the following SmartClient version : SmartClient Version: v12.1p_2022-07-19/PowerEdition Deployment (built 2022-07-19)
    Brower information : Google Chrome Version 114.0.5735.199 (Official Build) (64-bit)

    I set the type of some field to 'date' like the following in the ds.xml file.

    <field name="activationdate" type="date"></field>

    And, the client codes are like the following.

    final ListGridField activationDate = new ListGridField( "activationdate", "Activation Date");

    BTW, the Data Chooser control does not get the exact date selected in ListGrid Filter.

    Is there any other setting I need to configure to make it work correctly?

    Hi Ted,

    There isn't anything that needs to be set in order for things to work correctly - if you take a look at the Showcase you'll see that date pickers work as you'd expect.

    Rather than an additional setting being required, it's more likely that you need to remove some kind of customization that you have applied which is invalid in some way.

    Please take a look at this overview:

    We suspect that you may have installed custom date parsing that doesn't handle current dates.

    If that hint doesn't help to solve your problem, the next step would be to make it possible for us to reproduce the problem.



      I did not applied any customization except 'setCellFormatter()' to display date only not including time.
      It shows the same behavior even if I do not apply it.

      When I change the type from 'date' to 'datetime' in ds.xml, it works fine but it shows the time selection option.
      Please see the following.

      I don't think I installed custom date parsing.

      My codes are very straightforward as I already shown above.
      So, I think you can easily reproduce it.


        That's good news, when we can reproduce something we can always rapidly fix it, and that's what we're here for!

        However, can you explain how specifically we should reproduce this issue - we have some advice here for how to make it possible for us to reproduce a problem.

        As soon as we can reproduce the problem, if it's a bug, we'll fix it!


          The points of my codes are like the following.

          (1) Client codes example.

          ListGrid grid = new ListGrid();

          (2) Data source example.

          file name : listds.ds.xml

          <field name="activationdate" type="date"></field>

          (3) SQL server example.

          table name : list

          include the following column.
          - column name : activationdate, data type : datetime2


            Hi Ted, to clarify, in order to help, we need a way to reproduce the problem. The code you've shown so far does not reproduce the problem.

            However, two things to note:

            1) in general, if you change the format in which dates are edited, you must also change the parser to match that format.

            You have not shown any code that changes the format in which dates are edited (a cell formatter just changes the way dates are displayed, not how they are edited). However, the symptoms you are experiencing almost always result from changing the edit format without changing the parser.

            Please take a look at these docs, in addition to the ones already recommended. It is likely that there is code in your application that attempts to change the display format (e.g. setNormalDisplayFormat()) but doesn't change the input format to match e.g. setInputFormat().


            2) you mention that you have a datetime column in your DB but you have declared the field as just type "date"

            It's not clear what you hope to happen here - we would recommend reviewing the Date and Time overview we previously linked:


            .. and thinking carefully about what you expect to happen regarding filtering, editing and so forth.



              (1) It is strange that you cannot reproduce the issue because we could reproduce in every place of codes by just changing the field type from 'datetime' to 'date' in ds.xml.

              (2) We do not edit the column but just read the date from the DB through ds.xml, so we do not have any decoration codes.

              (3) Now I changed the data type of DB column from datetime2 to date, but the result is same.

              Our codes are very simple as I mentioned above.
              Just read the data from DB and show them in list grid.
              There is no additional format added.

              I think you want me to check the following showcase which works fine.

              However, our codes use ds.xml instead.
              Then, do you have any example which works fine using ds.xml same as I did?


                The fact that we can't reproduce the problem means suggest that there is code in your project that you are not aware of - and it's probably the type of code we suggested you might have.

                Another possibility is something in your skin, or perhaps a locale file that is out of date or corrupted in some way.

                Please see the Debugging overview that we previously linked above:


                This is the right process to follow to isolate the problem.



                  I found that we overrode the parse like the following codes and it caused the issue.

                  DateUtil.setDateParser(new DateParser() {
                  public Date parse(String dateString) {
                  if (dateString == null) {
                  return null;
                  Date date = DateTimeFormat.getFormat("yyyy/MM/dd").parse(dateString);
                  return date;

                  I changed the following line and it corrected the issue.
                  Date date = DateTimeFormat.getFormat("MM/dd/yyyy").parse(dateString);

                  Then, may I know why the format "MM/dd/yyyy" works fine, but the format "yyyy/MM/dd" does not work?


                    Ah, so instead, there is DateUtil code exactly as we indicated.

                    The parser must reflect the format of the date as it is being edited. The format when the date is displayed doesn't matter.

                    However, you should remove your custom parser altogether, because you have degraded the system by installing it: now, parsing is strict, and requires exactly a two digit month, two digit day, and full year, and exact punctuation, where is terrible UX: for example, "5.5.23" is rejected.

                    Instead, if you need to change the MDY order, just call DateUtil.setInputFormat() and the default, intelligent parsing will remain.

                    But you don't even need to do that, either. If you just load the proper locale, that already sets the correct parsing order and correct formatting for the locale.

                    So basically just delete all the code you wrote around date handling and just load the locale, and you'll be done.