kor TürkçeGitHub

Variants

Saves and reapplies named views of connected controls.

kor/ui/VariantsSource

When to use

  • Let users return to a set of filters or a grid layout they use frequently.

Examples

Save a grid view

Sort a column, save the view, then use the menu to switch between the standard and saved views.

Loading the example

<k:Stack gap="10">
	<k:Stack row="true" gap="8">
		<k:Variants id="views" targets="grid" standardText="Standard orders"/>
		<k:Button text="Save current view" press=".onSave"/>
	</k:Stack>
	<k:DataGrid id="grid" rows="{/orders}" height="13rem" label="Orders">
		<k:columns>
			<k:Column label="Order" path="id" width="100"/>
			<k:Column label="Customer" path="customer" grow="1"/>
			<k:Column label="Amount" path="amount" type="number"/>
		</k:columns>
	</k:DataGrid>
</k:Stack>

Restore an order filter

Choose the supplied view to filter to Aster orders. Bind variants and listen for change if the application manages storage.

Loading the example

<k:Stack gap="10">
	<k:Variants targets="filter grid" variants="{/views}" select=".onSelect"/>
	<k:FilterBar id="filter" placeholder="Search customers or amounts" change=".onFilter">
		<k:FilterField label="Customer" path="customer"/>
		<k:FilterField label="Amount" path="amount" type="number" unit="TRY"/>
	</k:FilterBar>
	<k:DataGrid id="grid" rows="{/orders}" height="13rem" label="Orders">
		<k:columns>
			<k:Column label="Order" path="id" width="100"/>
			<k:Column label="Customer" path="customer" grow="1"/>
			<k:Column label="Amount" path="amount" type="number"/>
		</k:columns>
	</k:DataGrid>
</k:Stack>

API

Properties

NameTypeDefaultDescription
variantsobjectnullArray of saved views
selectedKeystringstandardKey of the selected view
standardTextstringLabel of the standard view
storageKeystringBrowser storage key. Empty disables browser storage
shareablebooleanfalseWhether to offer the share option
titlebooleanfalseWhether to use heading typography

Associations

NameTypeDescription
targetssap.ui.core.Control[]Controls whose state is saved and restored

Events

NameTypeDescription
changevariants: objectSaved views changed through creation, removal, rename or default selection
selectkey: stringA saved view was applied

Methods

NameDescription
apply(key: string): voidApplies the view with the supplied key
saveAs(name: string, options: { isDefault?: boolean; shared?: boolean } = {}): voidSaves the current state under a new name
save(): voidOverwrites the selected view with the current state
type Variant = { key: string; name: string; state: Record<string, unknown>; isDefault?: boolean; shared?: boolean; locked?: boolean };

Related

FilterBarDataGridTreeGrid