Announcement

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

    selectItem and return values

    SmartClient Version: SNAPSHOT_v8.3d_2012-09-27/PowerEdition Deployment (built 2012-09-27)
    -------------------------------

    Dear Specialists, I have a problem with the SelectItem.

    I create a SelectItem with an option datasource. And using manually everything is fine:
    Code:
    tariffModel = new SelectItem("TariffModel", "Tariff Model");
            tariffModel.setValueField("TariffModelID");
            tariffModel.setDisplayField("TariffModelName");
            tariffModel.setOptionDataSource(DataSource.getDataSource("tbTmdTariffModel"));
            tariffModel.setOptionCriteria(new Criteria("ContractVersionID", contractVersionID));
            tariffModel.setOptionOperationId("tariffModelOfContractVersion");
            tariffModel.setSortField("TariffModelName");
            tariffModel.setMultiple(true);
            tariffModel.setMultipleAppearance(MultipleAppearance.PICKLIST);
            tariffModel.setDefaultToFirstOption(true);
    But in our application the user can hit a button that should automatically select another value in the picklist:
    Code:
    tariffModel.setValues(tariffModelID.toString());
    System.out.println(Arrays.toString(tariffModel.getSelectedRecords()));
    generateBusinessCaseOverview();
    From the GUI point of view, this works fine. The correct value is selected in the display. But getSelectedRecords() will always return the value I set in code and the prevously selected value(s)! But the previusly selected values are not selected in the GUI. When I click the arrow of the SelectItem and open the picklist (but not necessarily change the selection), getSelectedRecords will return only the selected value from now on.

    It is like getSelectedRecords is not updated by setValue(s), only by an GUI event. How can I solve this?

    Thanks!

    #2
    Because of load on demand, records that are selected by a programmatic call to setValues() may not be loaded, so there is no way we could return them to you directly - we would have to do a server trip and it would require a callback or event to notify you of loading them.

    By design, we don't currently do this. But you can fetch the selected records yourself using DataSource.fetchData() and passing criteria that would select them (generally just a big OR Criteria to select the records by listing off their primary keys).

    Comment


      #3
      Thank you, an invalidateCache() called on the datasource clears the selections (that are not selected anymore).

      I do not quite understand why, because all what has to be selected and deselected is already in the list, but it works. Thank, you.

      Comment

      Working...
      X