Announcement

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

    RelativeDatetem problem with RelativeDateRangePosition.END for type Date

    Since upgrade from smart gwt 3 to smart gwt5 (current version is 5.0p.2016-06-25) we noticed strange behavior for the component RelativeDateItem. (Browser: FF 26 version and other)
    Unfortunately, I can't find any showcases with such component.
    We create 2 RelativeDateItem items on the forms :one is with setRangePosition(RelativeDateRangePosition.START) and another one with setRangePosition(RelativeDateRangePosition.END) and both of them have type "date".
    But in our ds.xml file we have type as "datetime".We use this fields, as criteria for fetch.We implement it like this because we don't want to allow user to see time and to change it.(only date should be visible in the input component).
    We also noticed if we change type to "datetime" in RelativeDateItem component everything is ok, but user can change the time. We only want that user select date from calendar and automatically (as we set rangeposition) this date will be transformed to the start of day (00:00:00) and to the end of the day(23:59:59) accordingly. But by default we have 00:00:00 for both items.
    Can you please explain such behavior?Is it a bug?Or it was changed by design?
    In smartgwt 3 version it works good.

    I just wanted also to mention that if to compare request from RPC console for smart gwt 3 version and smart gwt 5 version then we can see the next difference:
    smart gwt 3 version (date and time in the request):
    {
    dataSource:"datasourceName",
    operationType:"fetch",
    componentId:"isc_BasicStatisticsGrid_Card_statistics_grid_0",
    data:{
    operator:"and",
    criteria:[

    {
    operator:"greaterOrEqual",
    value:"2016-06-28T00:00:00",
    fieldName:"datetime_from"
    },
    {
    operator:"lessOrEqual",
    value:"2016-07-04T23:59:59",
    fieldName:"datetime_to"
    }
    ]
    }

    smart gwt 5 version (only date in request):

    {
    dataSource:"datasourceName",
    operationType:"fetch",
    componentId:"isc_BasicStatisticsGrid_Card_statistics_grid_0",
    data:{
    operator:"and",
    criteria:[

    {
    operator:"greaterOrEqual",
    value:"2016-06-28",
    fieldName:"datetime_from"
    },
    {
    operator:"lessOrEqual",
    value:"2016-07-04",
    fieldName:"datetime_to"
    }
    ]
    }
    Last edited by ksenia_korenkova; 7 Jul 2016, 05:39.

    #2
    A field of type "date" is not expected to produce criteria that includes a time-portion, and UI elements like DateChoosers didn't support time-editing in SmartGWT 3.0.

    You didn't give any detail about how you're getting those criteria (dynamicForm.getValuesAsCriteria(), relativeDateItem.getCriterion(), etc), but assuming you have a custom form with two relativeDateItems in it, and you call form.getValuesAsCriteria(), you should be able to get the criteria you want with these attributes on your relativeDateItems:

    Code:
    // produce datetime values
    setType("datetime");
    
    // format values as date-only
    setDateFormatter(DateDisplayFormat.TOSHORTDATE);
    
    // edit values as date-only - hide the time-editor in the pop-up dateChooser
    setShowPickerTimeItem(false);
    Alternatively, you could pass the values of your items to DateUtil.get[Start/End]Of().

    Note that there are UI components that will manage this range-criteria job for you - see MiniDateRangeItem and DateRangeItem.

    Note also that, if you're upgrading your version of SmartGWT, there's no reason to upgrade now to a version that's already superceded by two newer releases. You should upgrade to 5.1 at least, if not 6.0 - 5.0 is less likely to receive complex fixes, or fixes that apply specifically to browser-versions released since 5.0 was released.
    Last edited by Isomorphic; 7 Jul 2016, 20:58.

    Comment

    Working...
    X