Documentation

Item class

Class represents dialog item.

Constructor

constructor(itemOptions: ItemOptions): Item

Creates class object Item. Use the method dialog.addItem() or the option items in Dialog class constructor for adding items in the dialog .

itemOptions — item options, defined by the structure ItemOptions.

export type ItemOptions = {
	id: number | string,
	entityId: string,
	entityType?: string,
	title?: string | TextNodeOptions,
	subtitle?: string | TextNodeOptions,
	supertitle?: string | TextNodeOptions,
	caption?: string | TextNodeOptions,
	captionOptions?: CaptionOptions,
	avatar?: string,
	avatarOptions?: AvatarOptions,
	textColor?: string,
	link?: string,
	linkTitle?: string | TextNodeOptions,
	badges?: ItemBadgeOptions[],
	badgesOptions?: BadgesOptions,
	tagOptions?: { [key: string]: any },
	tabs?: string[],
	searchable?: boolean,
	saveable?: boolean,
	deselectable?: boolean,
	selected?: boolean,
	hidden?: boolean,
	children?: ItemOptions[],
	nodeOptions?: ItemNodeOptions,
	customData?: { [key: string]: any },
	sort?: number,
};

  • id: number | string

    Item ID. Required parameter.


  • entityId: string

    Entity ID. Required parameter.


  • entityType?: string

    Entity type. Set as default.


  • title?: string | TextNodeOptions

    Item title.
    Defined either by string or structure TextNodeOptions.
    When values is not set, prints item with empty title.


  • subtitle?: string | TextNodeOptions

    Item subtitle.
    Defined either by string or structure TextNodeOptions. When value is not set, searches subtitle in the entity settings.


  • supertitle?: string | TextNodeOptions

    Item supertitle.
    Defined either by string, or structure TextNodeOptions.
    When value is not set, searches the supertitle in the entity settings.


  • caption?: string | TextNodeOptions

    Item capture. Displayed right next to title.
    Defined either by string or structure TextNodeOptions.
    When value is not set, searches caption in entity settings.


  • captionOptions?: CaptionOptions

    Additional settings for item caption. Defined by structure CaptionOptions.

    export type CaptionOptions = {
      fitContent: boolean,
      maxWidth: number | string
    };
    

    • fitContent — when set as true, block width with caption will be defined by text width.
    • maxWidth — maximum caption width. Defined in pixels (specified by integer) or with unit of measurement (specified by string).

    When value is not set, searches settings in entity settings.


  • avatar?: string

    Item avatar. Indicates either image path or file in format Data URL.
    When value is not set, searches avatar in entity settings.


  • avatarOptions?: AvatarOptions

    Additional item avatar settings. Defined by structure AvatarOptions.

    export type AvatarOptions = {
      bgColor?: string,
      bgSize?: string,
      bgImage?: string,
    };
    

    • bgColor — avatar background color. Set by CSS property background-color values.
    • bgSize — avatar background size. Set by CSS property background-size values.
    • bgImage — background image. Set by CSS property background-image values.

    When value is not set, searches settings in the entity settings.


  • textColor?: string

    Title text color. When value is not set, searches title text color in the entity settings.


  • link?: string

    "More" link URL. When value is not set, searches link URL in the entity settings.


  • linkTitle?: string | TextNodeOptions

    "More" link URL.
    Defined either by string or structure TextNodeOptions.
    When value is not set, searches URL title in the entity settings.


  • badges?: ItemBadgeOptions[]

    Array with item badges.
    Each badge is defined by the structure ItemBadgeOptions.
    When values is not set, searches badges in the entity settings.


  • badgesOptions?: BadgesOptions

    Additional settings for block with badges. Defined by structure BadgesOptions.

    export type BadgesOptions = {
      fitContent: boolean,
      maxWidth: number | string
    };
    

    • fitContent — when set as true, badges block width will be defined by width of all badges.
    • maxWidth — maximum width of block with badges. Defined in pixels (specified by integer) or with unit of measurement (specified by string).

    When value is not set, searches settings in the entity settings.


  • tagOptions?: { [key: string]: any }

    Item display settings in the widget TagSelector.

    • bgColor — background color.
    • textColor — title color.
    • maxWidth — maximum item width.
    • fontWeight — item title font style.
    • avatar — item avatar.
    • link — item link.
    • title — item title.

    When value is not set, searches settings in the entity settings.


  • tabs?: string | string[]

    Identifier or array with tab IDs, showing the item. Optional parameter. When binding to tab is not specified, item is still can be found using the search.


  • searchable?: boolean

    When set as false this item won't be found in search. Default value: true.


  • saveable?: boolean

    When set as false this item won't be saved for "Recent" tab. Default value: true.


  • deselectable?: boolean

    When set as false this item cannot be deselected. Default value: true.


  • selected?: boolean

    When set as true the item will be selected automatically. The event Item:onSelect is not executed in this case. Default value: false.


  • hidden?: boolean

    Flag, designating a hidden item.


  • children?: ItemOptions[]

    Array with child items. Used for creating a tree structure.


  • nodeOptions?: ItemNodeOptions

    Additional settings for item DOM-node.
    Defined by structure ItemNodeOptions.


  • customData?: { [key: string]: any }

    Arbitrary additional item data.


  • sort?: number

    Item sorting index, used to sort items in the "Recent" tab, as well as in search query results. Not specified by default.

Methods

Method Description Available from version
getId(): string | number Returns item ID.
getEntityId(): string Returns entity ID.
getEntity(): Entity Returns entшен object.
getEntityType(): string Returns entity type. When tye was not specified, returns default.
getTitle(): string Returns item title. When title is not specified, returns an empty string.
setTitle(title: ?string | TextNodeOptions): void Sets item's title.
Title is defined by either a string or structure TextNodeOptions.
getSubtitle(): ?string Returns item subtitle.
When item's value is not specified, searches subtitle in the entity settings.
setSubtitle(subtitle: ?string | TextNodeOptions): void Sets item subtitle.
Subtitle is defined either by string or structure TextNodeOptions.
getSupertitle(): ?string Returns item supertitle.
When item's value is not specified, searches supertitle in the entity settings.
setSupertitle(supertitle: ?string | TextNodeOptions): void Sets item's supertitle.
Supertitle is defined either by string or structure TextNodeOptions.
getCaption(): ?string Returns item's caption.
When item's value is not specified, searches caption in the entity settings.
setCaption(caption: ?string | TextNodeOptions): void Sets item's caption.
Caption is defined either by string or by structure TextNodeOptions.
getAvatar(): ?string Returns item's avatar. When item's value is not specified, searches avatar in the entity settings.
setAvatar(avatar: ?string): void Sets item's avatar.
Indicate either image path or file in Data URL. format
getAvatarOption(option: $Keys): string | boolean | number | null Returns option value for item's avatar setup.
option оname is set by structure keys AvatarOptions.
When item's values is not set, searches avatar in the entity settings.
21.600.0
setAvatarOption(option: $Keys, value: string | boolean | number | null): void Sets option value for item avatar.
option name is defined by keys of structure AvatarOptions.
setAvatarOptions(options: AvatarOptions): void Sets additional settings for item's avatar.
option settings are defined by the structure AvatarOptions.
getTextColor(): ?string Returns title text color.
When item's value is not set, searches text color in the entity settings.
setTextColor(textColor: ?string): void Sets title text color.
getLink(): ?string Returns "More" link URL.
When item's value is not set, searches link URL in the entity settings.
setLink(link: ?string): void Sets "More" link address.
getLinkTitle(): ?string Returns "More" link title.
When item's value is not set, searches link title in the entity settings.
setLinkTitle(linkTitle: ?string | TextNodeOptions): void Sets "More" link title.
Title is defined either by string or structure TextNodeOptions.
getBadges(): ItemBadge[] Returns array with item's badges (class objects ItemBadge). When item's value is not set, searches badges in the entity settings.
setBadges(badges: ?ItemBadgeOptions[]): void Sets item's badges.
Each badge is defined by the structure [link=13509944]ItemBadgeOptions[/link].
getDialog(): Dialog Returns object of dialog (object of class Dialog), в который добавлен элемент.
createNode(nodeOptions: ItemNodeOptions): ItemNode Creates item's new DOM-node.
  • nodeOptions — settings for item's DOM-node. Defined by structure ItemNodeOptions.
removeNode(node: ItemNode): void Deletes item's DOM-node.
getNodes(): Set Returns collection of DOM-nodes (class objects [link=13509304]ItemNode[/link]).
select(preselectedMode: boolean = false): void Preselects an item.
deselect(): void Deselects an item.
isSelected(): boolean Returns true when item is selected.
setSearchable(flag: boolean): void Sets or cancels item participation in search.
isSearchable(): boolean Returns true when item participates in search.
setSaveable(flag: boolean): void Sets or disables item saving for the "Recent" tab.
isSaveable(): boolean Returns true when item selection is saved for "Recent" tab.
setDeselectable(flag: boolean): void Sets or disables option to deselect an item.
isDeselectable(): boolean Returns true when item can be deselected.
setHidden(flag: boolean): void Sets or cancels "hidden" status for item.
isHidden(): boolean Returns true when item is hidden.
setSort(sort: ?number): void Sets item sorting.
getSort(): ?number Returns item sorting.
resetSearchIndex(): void Resets item search index.
getCustomData(): Map Returns collection of additional item data.
isRendered(): boolean Returns true when item was added and rendered in the dialog.
getTagBgColor(): ?string Returns background color for item in widget TagSelector.
getTagTextColor(): ?string Returns title color for item in widget TagSelector.
getTagMaxWidth(): ?number Returns maximum width for item in widget TagSelector.
getTagFontWeight(): ?string Returns font style for item title in widget TagSelector.
getTagAvatar(): ?string Returns avatar for item in widget TagSelector.
getTagLink(): ?string Returns link address for item in widget TagSelector.

© «Bitrix24», 2001-2024
Up