@openui5/sap.m
Version:
OpenUI5 UI Library sap.m
139 lines (126 loc) • 3.95 kB
JavaScript
/*!
* OpenUI5
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
*/
sap.ui.define([
"./QuickActionItem",
"./QuickAction",
"sap/m/SegmentedButton",
"sap/m/SegmentedButtonItem",
"sap/m/library",
"sap/ui/core/Lib",
"sap/ui/core/library",
"sap/ui/performance/trace/FESRHelper"
], function(
QuickActionItem,
QuickAction,
SegmentedButton,
SegmentedButtonItem,
library,
Library,
CoreLibrary,
FESRHelper
) {
"use strict";
/**
* Constructor for a new <code>QuickSortItem</code>.
*
* @param {string} [sId] ID for the new <code>QuickSortItem</code>, generated automatically if no ID is given
* @param {object} [mSettings] Initial settings for the new <code>QuickSortItem</code>
*
* @class
* The <code>QuickSortItem</code> class is used for items for the <code>sap.m.table.columnmenu.QuickSort</code>.
* It can be used to specify control- and application-specific items for sorting.
*
* @extends sap.m.table.columnmenu.QuickActionItem
*
* @author SAP SE
* @version 1.146.0
*
* @public
* @since 1.110
*
* @alias sap.m.table.columnmenu.QuickSortItem
*/
var QuickSortItem = QuickActionItem.extend("sap.m.table.columnmenu.QuickSortItem", {
metadata: {
library: "sap.m",
properties: {
/**
* Specifies the sort order that is applied for the respective column.
*/
sortOrder: { type: "sap.ui.core.SortOrder", defaultValue: CoreLibrary.SortOrder.None }
},
aggregations: {
/**
* Defines the quick action of the quick sort item.
*/
quickAction: { type: "sap.m.table.columnmenu.QuickAction", multiple: false, visibility: "hidden" }
}
}
});
QuickSortItem.prototype._getAction = function() {
var oQuickAction = this.getAggregation("quickAction");
var sLabel = this.getLabel();
if (oQuickAction) {
oQuickAction.setLabel(sLabel);
} else {
oQuickAction = new QuickAction({
label: sLabel,
content: [this._createContent()],
category: library.table.columnmenu.Category.Sort,
contentSize: library.InputListItemContentSize.L
});
}
this.setAggregation("quickAction", oQuickAction, true);
return oQuickAction;
};
QuickSortItem.prototype._createContent = function() {
const oBundle = Library.getResourceBundleFor("sap.m");
const oSortNoneButton = new SegmentedButtonItem({
icon: "sap-icon://menu2",
key: "None",
tooltip: oBundle.getText("table.COLUMNMENU_SORT_NONE")
});
const oSortAscendingButton = new SegmentedButtonItem({
icon: "sap-icon://sort-ascending",
key: "Ascending",
tooltip: oBundle.getText("table.COLUMNMENU_SORT_ASCENDING")
});
const oSortDescendingButton = new SegmentedButtonItem({
icon: "sap-icon://sort-descending",
key: "Descending",
tooltip: oBundle.getText("table.COLUMNMENU_SORT_DESCENDING")
});
FESRHelper.setSemanticStepname(oSortNoneButton, "press", "tbl:p13n:sort:none");
FESRHelper.setSemanticStepname(oSortAscendingButton, "press", "tbl:p13n:sort:asc");
FESRHelper.setSemanticStepname(oSortDescendingButton, "press", "tbl:p13n:sort:desc");
return new SegmentedButton({
selectedKey: this.getSortOrder(),
items: [
oSortNoneButton,
oSortAscendingButton,
oSortDescendingButton
],
selectionChange: [{item: this}, this._onSortChange, this]
});
};
QuickSortItem.prototype._onSortChange = function (oEvent, mSortInfo) {
this.setSortOrder(oEvent.getSource().getSelectedKey(), true);
this.getParent().onChange(mSortInfo.item);
};
/*
* @see JSDoc generated by SAPUI5 control API generator
*/
QuickSortItem.prototype.setSortOrder = function(sSortOrder) {
this.setProperty("sortOrder", sSortOrder, true);
var oQuickAction = this.getAggregation("quickAction");
if (oQuickAction) {
var oSegmentedButton = oQuickAction.getContent()[0];
oSegmentedButton.setSelectedKey(sSortOrder);
}
return this;
};
return QuickSortItem;
});