Announcement

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

    listgrid date filter format

    This is something I have never got this right. Let me start from the beginning: We use listgrid to filter only on the server side, so no client side filtering, and filter button is hidden and FilterEditorSubmitHandler is set to event.cancel();
    so User really cannot do anything until clicks custom filter button in the page. We do on the server side get data and provide to the gird, gird only needs to show them. No fetch data, no client side criteria is set. So no client side filter is used in this case due to requirement.
    so We do query against Criteria criteria = grid.getFilterEditorCriteria(); criteria, since user does not click filter button, grid.getCriteria() is null or empty and does not reflect user input. I implemented some ugly hack to read input data from grid.getFilterEditorCriteria();

    All it is good so far.
    When user selects date from filter, I get following:

    Click image for larger version

Name:	Elbek Company-right.jpg
Views:	163
Size:	26.2 KB
ID:	234478


    So date is in this format: MM/dd/yyyy HH:mm

    when user clicks custom filter button I go to server get the data and do following: grid.fetchData(grid.getFilterEditorCriteria());

    So grid.getCriteria() and grid.getFilterEditorCriteria()' matches to each other. But when I do so, it messes up the date and it ends up being like this:
    Click image for larger version

Name:	Elbek Company-wrong.jpg
Views:	148
Size:	18.2 KB
ID:	234479


    I tried all possible ways to correct this format without luck.

    Code:
    one of the try : grid.getFilterEditorCriteria().addCriteria("started", DateTimeFormat.getFormat("MM/dd/yyyy HH:mm").format(new Date(longValue))));
    other one: grid.getFilterEditorCriteria().addCriteria("started", new Date(longValue)));
    No luck.

    is there any way to control format of the date filter and how to add date filter in the criteria so when apply this grid.getFilterEditorCriteria() to criteria it won't mess up input.

    this is how started field defined in datasource:

    Code:
            DataSourceDateTimeField STARTED = new DataSourceDateTimeField("started");
            STARTED.setDateFormatter(DateDisplayFormat.TOUSSHORTDATETIME);

    I really need a help on this.

    Thanks in advance.
    Attached Files

    #2
    Read the Date and Time Format and Storage overview. You seem to be expecting to work with Strings where in fact Date instances are expected.

    Just grid.fetchData(grid.getFilterEditorCriteria()) doesn't produce the issue you show. If you think that's a framework bug and not a usage issue, try putting together a minimal, ready-to-run test case and we can take a look. This is usually best done by modifying an existing product sample to add the code you think is the problem.

    Comment


      #3
      I am passing date:
      Code:
      grid.getFilterEditorCriteria().addCriteria("started", new Date(longValue)));
      DataSourceDateTimeField STARTED = new DataSourceDateTimeField("started");
      How else I should pass? this is not string, Any specific link to read?

      Thanks.

      Comment


        #4
        That part of your code is now correct.

        The specific doc to read is the " Date and Time Format and Storage" overview.

        Again, let us know if you can produce a test case that shows a framework bug.

        Comment

        Working...
        X