Showing results for 
Search instead for 
Did you mean: 

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

Active Contributor
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)


Right now there is a timing issue when using databinding which prevents the ViewSettingsDialog being updated with the selected sort item. Therefore a workaround would be to patch the ViewSettingsItem to synchronize the selection in the dialog:

ViewSettingsItem.prototype.setSelected = function(bValue) {
	this.setProperty("selected", bValue, true);
	// synchronize the selected sort item when databinding is used!
	this.getParent() && this.getParent().setSelectedSortItem(this);
	return this;

Answers (0)