Skip to Content
Jun 23, 2022 at 02:15 PM

"selectedSortItem" is not set on a ViewSettingsDialog via a JSONModel

90 Views Last edit Jun 24, 2022 at 06:52 AM 4 rev

I try to set the selected Sort Item on a ViewSettingsDialog via an JSONModel.

Unfortunately, the desired ViewSettingsItem is not set under the "sortItems" aggregation.

As a cross check, setting "sortDescending" with JSONModel works.

It also works when I enter the key directly. This example is also described here

Here is the ViewSettingsDialog:

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
  <ViewSettingsDialog id="linkHeaderViewSettingsDialog" confirm="handleConfirm" sortDescending="{settings>/sortOrderDecending}">
      <ViewSettingsItem key="downloadsCurrentFortnight" text="downloadsCurrentFortnight"/>
      <ViewSettingsItem key="downloadsCurrentMonth" text="downloadsCurrentMonth" />
      <ViewSettingsItem id="downloads365" key="downloads365" text="downloads365" selected="{= ${settings>/selectKey} === 'downloads365'}" />
      <ViewSettingsItem key="vscodeInstalls" text="vscodeInstalls"/>
      <ViewSettingsItem key="updatedAt" text="updatedAt" />
      <ViewSettingsItem key="createdAt" text="createdAt" />
      <ViewSettingsItem key="addedToBoUI5" text="addedToBoUI5" />

I created a minimum example here:

I deployed this on GitHub Pages here:

I also tried to set the "selected" property on "ViewSettingsItem" via JSONModel. That didnt work either.
I can of course set the settings in the controller to the JSONModel, but I would like to avoid that.

Latest OpenUI5 Version 1.103.0 is used here.

Can someone please help me here or nudge me in the right direction.