class sap.ui.model.DataState

Control sample: sap.ui.model.DataState
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/model/DataState
Application Component: CA-UI5-COR

Holds the status data of a binding. To react to changes of this status data, a control must implement the refreshDataState method, which is called with the name of the bound control property and the data state object as parameters. With the #getChanges method, the control can determine the changed properties and their old and new values.

    // sample implementation to handle message changes
    myControl.prototype.refreshDataState = function (sPropertyName, oDataState) {
       oDataState.getMessages().forEach(function (oMessage) {
           console.log(oMessage.getMessage());
       }
    }

    // sample implementation to handle laundering state
    myControl.prototype.refreshDataState = function (sPropertyName, oDataState) {
       this.setBusy(oDataState.isLaundering());
    }

    // sample implementation to handle dirty state
    myControl.prototype.refreshDataState = function (sPropertyName, oDataState) {
       if (oDataState.isDirty()) {
          console.log("Property " + sPropertyName + " of control " + this.getId()
              + " is dirty");
       }
    }

With the #getProperty method, the control can read a property of the data state. The properties are


Constructor

new sap.ui.model.DataState()

Methods Overview

Method Description
changed

Returns whether the data state is changed, or resets the data state in case the parameter bNewState is false; reset data state means that the data state properties are replaced with the changed properties. As long as there was no call to this method with bNewState set to false, the data state is dirty, and the corresponding binding will fire data state change events.

sap.ui.model.DataState.extend

Creates a new subclass of class sap.ui.model.DataState with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.base.Object.extend.

getChanges

Returns the changes of the data state in a map that the control can use in the refreshDataState method. The changed property's name is the key in the map. Each element in the map contains an object with the properties oldValue with the old property value and value with the new value of the property. The map only contains the changed properties.

getControlMessages

Returns the array of state messages of the control.

getInvalidValue

Returns the dirty value of a binding that was rejected by a type validation so that it could not be applied to the model. If the value was not rejected it returns undefined. In this case the current model value can be accessed using the #getValue method.

getMessages

Returns the array of this data state's messages combining the model and control messages. The array is sorted descendingly by message severity.

sap.ui.model.DataState.getMetadata

Returns a metadata object for class sap.ui.model.DataState.

getModelMessages

Returns the array of state messages of the model or undefined.

getOriginalValue

Returns the formatted original value of the data. The original value is the last confirmed value.

getValue

Returns the formatted value of the data state.

isControlDirty

Returns whether the data state is dirty in the UI control. A data state is dirty in the UI control if the entered value did not yet pass the type validation.

isDirty

Returns whether the data state is dirty. A data state is dirty if the value was changed but is not yet confirmed by a server or the entered value did not yet pass the type validation.

isLaundering

Returns whether the data state is in laundering. If data is sent to the server, the data state becomes laundering until the data was accepted or rejected.

setControlMessages

Sets an array of control state messages.

setInvalidValue

Sets the dirty value that was rejected by the type validation.

setLaundering

Sets the laundering state of the data state.

setModelMessages

Sets an array of model state messages.

setOriginalValue

Sets the formatted original value of the data.

setValue

Sets the formatted value of the data state,

changed

Returns whether the data state is changed, or resets the data state in case the parameter bNewState is false; reset data state means that the data state properties are replaced with the changed properties. As long as there was no call to this method with bNewState set to false, the data state is dirty, and the corresponding binding will fire data state change events.

Param Type DefaultValue Description
bNewState boolean

Whether the data state is to be reset

sap.ui.model.DataState.extend

Creates a new subclass of class sap.ui.model.DataState with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.base.Object.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

getChanges

Returns the changes of the data state in a map that the control can use in the refreshDataState method. The changed property's name is the key in the map. Each element in the map contains an object with the properties oldValue with the old property value and value with the new value of the property. The map only contains the changed properties.

getControlMessages

Returns the array of state messages of the control.

getInvalidValue

Returns the dirty value of a binding that was rejected by a type validation so that it could not be applied to the model. If the value was not rejected it returns undefined. In this case the current model value can be accessed using the #getValue method.

getMessages

Returns the array of this data state's messages combining the model and control messages. The array is sorted descendingly by message severity.

sap.ui.model.DataState.getMetadata

Returns a metadata object for class sap.ui.model.DataState.

getModelMessages

Returns the array of state messages of the model or undefined.

getOriginalValue

Returns the formatted original value of the data. The original value is the last confirmed value.

getValue

Returns the formatted value of the data state.

isControlDirty

Returns whether the data state is dirty in the UI control. A data state is dirty in the UI control if the entered value did not yet pass the type validation.

isDirty

Returns whether the data state is dirty. A data state is dirty if the value was changed but is not yet confirmed by a server or the entered value did not yet pass the type validation.

isLaundering

Returns whether the data state is in laundering. If data is sent to the server, the data state becomes laundering until the data was accepted or rejected.

setControlMessages

Sets an array of control state messages.

Param Type DefaultValue Description
aMessages sap.ui.core.Message[]

The control messages

setInvalidValue

Sets the dirty value that was rejected by the type validation.

Param Type DefaultValue Description
vInvalidValue any

The value that was rejected by the type validation or undefined if the value was valid

setLaundering

Sets the laundering state of the data state.

Param Type DefaultValue Description
bLaundering boolean

Whether the state is laundering

setModelMessages

Sets an array of model state messages.

Param Type DefaultValue Description
aMessages sap.ui.core.Message[] []

The model messages for this data state.

setOriginalValue

Sets the formatted original value of the data.

Param Type DefaultValue Description
vOriginalValue boolean

The original value

setValue

Sets the formatted value of the data state,

Param Type DefaultValue Description
vValue any

the value