API Reference > imodeljs-backend > ViewDefinitions > ViewDefinition ViewDefinition Class The definition element for a view. ViewDefinitions specify the area/volume that is viewed, the Ids of a DisplayStyle and a CategorySelector, plus additional view-specific parameters in their Element.jsonProperties. Subclasses of ViewDefinition determine which model(s) are viewed. Example: Obtaining the background color for a view /** Given a ViewDefinition, return its background color. * @param view The ViewDefinition of interest. * @return The background color for the view. * @note This is a convenience function intended to demonstrate the API. The background color is defined on the ViewDefinition's DisplayStyle. If multiple properties of the DisplayStyle are of interest, it would be more efficient to obtain the DisplayStyle via ViewDefinition.loadDisplayStyle() directly. */ function getViewBackgroundColor(view: ViewDefinition): ColorDef { const displayStyle: DisplayStyle = view.loadDisplayStyle(); // Load the view's display style from the IModelDb. return displayStyle.settings.backgroundColor; // Extract the background color. } note ViewDefinition is only available in the backend. See ViewState for usage in the frontend. Extends DefinitionElement Extended by ViewDefinition3d ViewDefinition2d Implements ViewDefinitionProps Methods Name Description getAuxiliaryCoordinateSystemId(): string The Id of the AuxiliaryCoordinateSystem for this ViewDefinition, or an invalid Id if no ACS is defined. isDrawingView(): this is DrawingViewDefinition Type guard for 'instanceof DrawingViewDefinition' isSpatialView(): this is SpatialViewDefinition Type guard for instanceof SpatialViewDefinition isView2d(): this is ViewDefinition2d Type guard for 'instanceof ViewDefinition2d` isView3d(): this is ViewDefinition3d Type guard for instanceof ViewDefinition3d loadCategorySelector(): CategorySelector Load this view's CategorySelector from the IModelDb. loadDisplayStyle(): DisplayStyle Load this view's DisplayStyle from the IModelDb. setAuxiliaryCoordinateSystemId(acsId: string): void Set or clear the AuxiliaryCoordinateSystem for this ViewDefinition. createCode(iModel: IModelDb, scopeModelId: string, codeValue: string): Code Static Create a Code for a ViewDefinition given a name that is meant to be unique within the scope of the specified DefinitionModel. Inherited methods Name Inherited from Description buildConcurrencyControlRequest(opcode: DbOpcode): void DefinitionElement Add a request for locks, code reservations, and anything else that would be needed to carry out the specified operation. delete(): void DefinitionElement Delete this Element from the iModel. forEachProperty(func: PropertyCallback, includeCustom: boolean = true): void DefinitionElement Call a function for each property of this Entity. getClassMetaData(): undefined | EntityMetaData DefinitionElement Get the class metadata for this element. getDisplayLabel(): string DefinitionElement Get a display label for this Element. getJsonProperty(nameSpace: string): any DefinitionElement Get a JSON property of this element, by namespace getPredecessorIds(): Id64Set DefinitionElement Get the Ids of this element's predecessors. getToolTipMessage(): string[] DefinitionElement Get a list of HTML strings that describe this Element for the tooltip. getUserProperties(namespace: string): any DefinitionElement Get a set of JSON user properties by namespace insert(): string DefinitionElement Insert this Element into the iModel. removeUserProperties(nameSpace: string): void DefinitionElement Remove a set of JSON user properties, specified by namespace, from this Element setJsonProperty(nameSpace: string, value: any): void DefinitionElement setUserProperties(nameSpace: string, value: any): void DefinitionElement Change a set of user JSON properties of this Element by namespace. update(): void DefinitionElement Update this Element in the iModel. is(otherClass: undefined): boolean Static DefinitionElement return whether this Entity class is a subclass of another Entity class onAllInputsHandled(_id: string, _iModel: IModelDb): void ProtectedStatic DefinitionElement Called on an element in a graph after all of its inputs have been processed and before its outputs are processed. onBeforeOutputsHandled(_id: string, _iModel: IModelDb): void ProtectedStatic DefinitionElement Called when a root element in a subgraph is changed and before its outputs are processed. onChildAdd(_arg: OnChildElementPropsArg): void ProtectedStatic DefinitionElement Called when an existing element is about to be updated so that an instance of this class will become its new parent. onChildAdded(_arg: OnChildElementIdArg): void ProtectedStatic DefinitionElement Called after an existing element has been updated so that an instance of this class is its new parent. onChildDelete(_arg: OnChildElementIdArg): void ProtectedStatic DefinitionElement Called when an element with an instance of this class as its parent is about to be deleted. onChildDeleted(_arg: OnChildElementIdArg): void ProtectedStatic DefinitionElement Called after an element with an instance of this class as its parent was successfully deleted. onChildDrop(_arg: OnChildElementIdArg): void ProtectedStatic DefinitionElement Called when an element with an instance of this class as its parent is about to be updated change to a different parent. onChildDropped(_arg: OnChildElementIdArg): void ProtectedStatic DefinitionElement Called after an element with an instance of this class as its previous parent was updated to have a new parent. onChildInsert(_arg: OnChildElementPropsArg): void ProtectedStatic DefinitionElement Called when a new element with an instance of this class as its parent is about to be inserted. onChildInserted(_arg: OnChildElementIdArg): void ProtectedStatic DefinitionElement Called after a new element with an instance of this class as its parent was inserted. onChildUpdate(_arg: OnChildElementPropsArg): void ProtectedStatic DefinitionElement Called when an element with an instance of this class as its parent is about to be updated. onChildUpdated(_arg: OnChildElementIdArg): void ProtectedStatic DefinitionElement Called after an element with an instance of this the class as its parent was updated. onDelete(arg: OnElementIdArg): void ProtectedStatic DefinitionElement Called before an Element is deleted. onDeleted(_arg: OnElementIdArg): void ProtectedStatic DefinitionElement Called after an Element was deleted. onInsert(arg: OnElementPropsArg): void ProtectedStatic DefinitionElement Called before a new Element is inserted. onInserted(arg: OnElementIdArg): void ProtectedStatic DefinitionElement Called after a new Element was inserted. onSubModelDelete(_arg: OnSubModelIdArg): void ProtectedStatic DefinitionElement Called when a sub-model of an instance of this class is being deleted. onSubModelDeleted(_arg: OnSubModelIdArg): void ProtectedStatic DefinitionElement Called after a sub-model of an instance of this class was deleted. onSubModelInsert(_arg: OnSubModelPropsArg): void ProtectedStatic DefinitionElement Called when an instance of this class is being sub-modeled by a new Model. onSubModelInserted(_arg: OnSubModelIdArg): void ProtectedStatic DefinitionElement Called after an instance of this class was sub-modeled by a new Model. onUpdate(arg: OnElementPropsArg): void ProtectedStatic DefinitionElement Called before an Element is updated. onUpdated(arg: OnElementIdArg): void ProtectedStatic DefinitionElement Called after an Element was updated. populateRequest(req: ConcurrencyControl.Request, props: ElementProps, iModel: IModelDb, opcode: DbOpcode, original: undefined | ElementProps): void Static DefinitionElement Disclose the codes and locks needed to perform the specified operation on this element Properties Name Type Description categorySelectorId string The element Id of the CategorySelector for this ViewDefinition details Accessor AbstractReadOnly ViewDetails Provides access to optional detail settings for this view. displayStyleId string The element Id of the DisplayStyle for this ViewDefinition Inherited properties Name Type Inherited from Description classFullName Accessor ReadOnly string DefinitionElement Get the full BIS class name of this Entity in the form "schema:class". classFullName Accessor StaticReadOnly string DefinitionElement Get the full BIS class name of this Entity in the form "schema:class" className Accessor ReadOnly string DefinitionElement The name of the BIS class associated with this class. code Code DefinitionElement The Code for this element federationGuid undefined | string DefinitionElement A FederationGuid assigned to this element by some other federated database id string DefinitionElement The Id of this Entity. iModel IModelDb DefinitionElement The IModelDb that contains this Entity isPrivate boolean DefinitionElement If true, don't show this DefinitionElement in user interface lists. jsonProperties Readonly { T } DefinitionElement Optional json properties of this element. model Readonly string DefinitionElement The ModelId of the Model containing this element parent undefined | RelatedElement DefinitionElement The parent element, if present, of this element. schema Static undefined DefinitionElement The Schema that defines this class. schemaName Accessor ReadOnly string DefinitionElement The name of the BIS Schema that defines this class userLabel undefined | string DefinitionElement A user-assigned label for this element. Defined in core/backend/src/ViewDefinition.ts Line 170 Last Updated: 12 June, 2024