Announcement

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

    How to add Relative Time entries for FilterBuilder Dates

    I use FilterBuilder to allow users to search a list of entries. One of the cells contains a date and I need users to be able to filter based on the weeks of the day. Basically, I want to be able to construct a filters like:
    Code:
    Monday this week 00:00 < Event date < Sunday this week 24:00
    Date events on the filter builder can be filtered as: 'Today', 'Yesterday', 'N days ago', etc. However, I would like to add a couple of entries into this combo box of the form: 'Monday current week', 'Sunday current week'. What is the best approach to do this?

    Thanks in advance,

    SmartClient Version: v9.0p_2013-11-09

    #2
    Use RelativeDateItem.presetOptions to manipulate the options shown in the dropdown.

    Comment


      #3
      Ok, thanks for the tip.
      This is how I actually implemented it:

      In the DataSource definition that drives the FilterBuilder, I set the Preset Options as a LinkedHashMap:

      Code:
      DataSourceDateTimeField annStartDateTime = new DataSourceDateTimeField("annStartDateTime", "Start Time");
      
      RelativeDateItem editorType = new RelativeDateItem();
      LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
      options.put("$startOfWeek","Start of week");
      options.put("$endOfWeek","End of week");		
      editorType.setPresetOptions(options);
      
      annStartDateTime.setEditorProperties(editorType);
      You can check the available options for the RelativeDataItem on
      http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/RelativeDate.html

      Comment

      Working...
      X