Announcement

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

    ListGrid: Can I set one field's filter valuemap based on another field's filter selection?

    Hi

    I have a Listgrid with several fields. Two have valuemaps for filtering. Say one is called Type and has values of A, B, C etc. The other is called SubType, and I would like to set the filter valuemap of SubType depending on what the user selects for Type e.g. if user is only interested in Type A then SubType's valuemap should just contain e.g. A1, A2 etc., but if the user decided to filter on Type B then SubType's choices would be B1, B2 etc. I'm expecting the valuemap for SubType to change as the user selects the Type filter, not when they initiate a fetch by clicking the funnel icon.
    Is this possible and if so may I have a clue please? I haven't been able to find an example.

    Thank you.

    SmartClient Version: v12.0p_2019-04-19/PowerEdition Deployment (built 2019-04-19)

    #2
    See the Dependent Selects samples. There's one for grids, one for forms.

    Comment


      #3
      Thank you Isomorphic, the hint sent me on the right path.

      In case anyone would find it useful:

      Code:
      SelectItem typeFilter = new SelectItem();
      typeFilter.addChangedHandler(new TypeFilterChangedHandler());
      type.setFilterEditorProperties(typeFilter);
      
      private class TypeFilterChangedHandler implements ChangedHandler {
          @Override
          public void onChanged(ChangedEvent changedEvent) {
              String typeFilterValue = (String)changedEvent.getValue();
              if (typeFilterValue == null) {
                  _subtype.setFilterEditorValueMap(new HashMap());
              } else {
                  _subtype.setFilterEditorValueMap(typeFilterValue.equals("A") ? _aStatusMap : _bStatusMap);
              }
          }
      }
      "type" is a ListGridField to which I add a SelectItem as a filter editor control. When the user changes the filter selection the sub-type filter value map is set appropriately from Maps I have already created.

      Comment

      Working...
      X