Announcement

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

    FilterBuilder setFieldPickerProperties

    Hi Isomorphic,

    I am attempting, in the FilterBuilder, to dynamically override which fields are displayed, and for some fields, dynamically override the field label, in the field SelectItem.

    I was hoping I could do something like the following, however, it does not appear to work.

    Any guidance would be appreciated.

    Thanks

    SmartClient Version: v10.1p_2016-02-24/Pro Deployment (built 2016-02-24)


    Code:
     SelectItem fieldPickerProperties = new SelectItem();
       
      LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
    ...
      // Populate field name/label value map dynamically, with the purpose of 1) dynamically omitting some fields, and 2) dynamically overriding the default label.
    ...
      fieldPickerProperties.setValueMap(valueMap);
       
      setFieldPickerProperties(fieldPickerProperties);

    #2
    Hi Isomorphic,

    I believe I have determined the correct way to achieve this.

    Code:
      DataSource fieldDs = new DataSource();
      fieldDs.setClientOnly(Boolean.TRUE);
      fieldDs.setFields(new DataSourceTextField("name"), new DataSourceTextField("title"), new DataSourceTextField("type"));
      DataSourceField[] fieldList = ds.getFields();
    List<ListGridRecord> recordList = new ArrayList<ListGridRecord>();
      for (DataSourceField field : fieldList) {
        if (!include(field)) continue;
       
        ListGridRecord r = new ListGridRecord();
        r.setAttribute("name", field.getName());
        r.setAttribute("title", getTranslatedTitle(field));
        r.setAttribute("type", field.getType());
        recordList.add(r);
      }
      fieldDs.setCacheData(recordList.toArray(new ListGridRecord[recordList.size()]));
      setFieldDataSource(fieldDs);
    However, I do have a question with respect to cleanup. Should I be destroying the fieldDs myself, or will the filter builder take care of that for me, along with the cached data associated with that fieldDs.

    Thanks

    Comment


      #3
      No, fields do not have a destroy() function, and do not need to be destroyed to be garbage collected.

      However your fieldDS does need to be destroy()d whenever you are done with it (probably at the same time this FilterBuilder gets destroy()d).

      Comment


        #4
        Thank you

        Comment

        Working...
        X