Class: Grid

bcdui.component.grid. Grid

Creates a grid front end based on given data or a configuration

new bcdui.component.grid.Grid(args)

component/grid/gridCreate.js, line 112
Name Type Description
args The parameter map contains the following properties:
Name Type Default Description
targetHtml targetHtmlRef A reference to the HTML DOM Element where to put the output
config bcdui.core.DataProvider ./gridConfiguration.xml optional The model containing the grid configuration data. If it is not present a SimpleModel with the url './gridConfiguration.xml' is created.
statusModel bcdui.core.DataProvider bcdui.wkModels.guiStatusEstablished optional StatusModel (default is 'guiStatusEstablished'), containing the filters as /SomeRoot/f:Filter
inputModel bcdui.core.DataProvider optional WRS or GridModel which is used, if not provided, it is generated out of the config. If provided, config is ignored unless it is set explicitly
id string optional The object's id, needed only when later accessing via id. If given the Grid registers itself at bcdui.factory.objectRegistry
hotArgs Object optional Arguments which are extended to handsontable creation
tooltipChain string | chainDef optional To overwrite default tooltip chain. An empty string will disable tooltips, otherwise the default gridTooltip.xslt is used
contextMenu boolean | string false optional If true, grid's default context menu is used, otherwise provide the url to your context menu xslt here.
customSave function optional Custom save function
afterAddRow function optional Custom function(args) which is called after a row was added (args.rowNode, wrs row node which was added, args.headerMeta wrs header object)
saveChain chainDef optional A chain definition which is used for the grid saving operation
saveParameters Object optional Parameters for the saving chain
loadChain chainDef optional A chain definition which is used for the grid loading operation
loadParameters Object optional Parameters for the loading chain
validationChain chainDef optional A chain definition which is used for the validation operation. basic wrs and reference validation is given by default
validationParameters Object optional Parameters for the validation chain
allowNewRows boolean true optional Allows inserting new rows via default contextMenu or drag/paste
columnFilters boolean false optional Enable basic column filter input fields
maxHeight integer optional Set a maximum vertical size in pixel (only used when no handsontable height is set)
isReadOnly boolean false optional Turn on viewer-only mode
topMode boolean false optional Add/save/restore buttons appear at the top, pagination at bottom, insert row at top
forceAddAtBottom boolean false optional Always add a new row at the bottom, no matter if topMode or pagination
disableDeepKeyCheck boolean false optional Set this to true if you really want to disable the deep key check which is active if your grid is only a subset of the underlying table
isReadOnlyCell function optional Custom check function if a given cell is read only or not. Function gets gridModel, wrsHeaderMeta, rowId, colId and value as input and returns true if the cell becomes readonly
columnFiltersGetCaptionForColumnValue function optional Function which is used to determine the caption values for column filters. You need to customize this when you're e.g. using XML data in cells.
columnFiltersCustomFilter Object optional CustomColumnFilter functions passed to column filter
defaultButtons boolean true optional Set to false if you want to hide the default buttons reset/delete/save
serverSidedPagination boolean false optional Set to true if you want to enable server sided pagination
paginationSize integer 20 optional Set pagination page size (and enable pagination)
paginationAllPages boolean false optional Set pagination show all option (and enable pagination)
requestPostChain chainDef optional The definition of the transformation chain

Extends

Members

constantchainLoadedStatusbcdui.core.status.ChainLoadedStatus

A status reached when the chain model is ready.
This (final) status is reached when the chain model could not be loaded.

constantchainStylesheetLoadingFailedbcdui.core.status.ChainStylesheetLoadingFailed

This (final) status is reached when the loading of a chain stylesheet has failed.

constantidstring

A globally unique id of the object. DataProviders do also register themselves at bcdui.factory.objectRegistry when an id is provided to the constructor. This id is only needed in declarative contexts, like jsp or, when a DataProvider is accessed in a xPath like . If not provided in the constructor, a random id starting with 'bcd' is set, but the object is not automatically registered.

constantinitializedStatusbcdui.core.status.InitializedStatus

This status is set when the constructor has set all parameters.

constantloadFailedStatusbcdui.core.status.LoadFailedStatus

This (final) status is reached when an error occurs during the loading or transformation process.

constantloadingStatusbcdui.core.status.LoadingStatus

The status code activated as soon as the loading begins.

constantsavedStatus

Example
if( model.getStatus() === model.savedStatus )
  ...

constantsaveFailedStatus

constanttransformedStatusbcdui.core.status.TransformedStatus

The status code is reached when everything is finished and the transformation result is available. This is the final state of the TransformationChain process if no error occurs.

constanttransformFailedStatusbcdui.core.status.TransformFailedStatus

The status code is reached when a transformation failed and operation cannot proceed

constanttransformingStatusbcdui.core.status.TransformingStatus

As long as this status is active the XSLT transformations are running.

constantwaitingForParametersStatusbcdui.core.status.WaitingForParametersStatus

This status is kept as long as the transformation chain is waiting for parameters to load and when the chain has already loaded.

Methods

actionReset()

component/grid/gridCreate.js, line 3388
Drop all changes and load fresh data

inherited addDataProvider(newDataProvider, newName){bcdui.core.DataProvider}

Adds a new data provider to the transformation chain. If there is already a data provider with the given name it is replaced.
Name Type Description
newDataProvider Object the new dataprovider which should be added
newName string optional an optional new name for the provider. if given an alias will be created
Returns:
Type Description
bcdui.core.DataProvider The old data provider registered under the name or null if there has not been any.

inherited addStatusListener(args)

Listen for any status to be reached. For use cases with the ready status (by far the most common), see onReady() and onceReady() convenience functions.
Name Type Description
args function | StatusListener | AddStatusListenerParam Either a function executed on all status transitions or a parameter map AddStatusListenerParam

inherited debugIsWaitingFor(){string}

Returns:
Type Description
string Human readable message, which DataProviders, this DataProvider depends on, are not currently in ready state

inherited debugStatus(){string}

Returns:
Type Description
string Human readable message about the current state state
Name Type Description
args boolean | ExecuteParam either true for forced or parameter map

inherited fetchData(){Promise}

asynchronously fetch data for this data provider.
Returns:
Type Description
Promise resolving once data has been loaded, first argument is this instance
Example
new bcdui.core.SimpleModel("data.xml").fetchData().then((dp)=>{ console.info(dp.getData()); })
This informs modification listeners, registered via onChange(args), that a change set was completed and data is consistent again.
Example
// Use of data modification events
var model = new bcdui.core.StaticModel({ data: { value: 3 } });
model.execute();
model.onChange( function(m) {
  console.log(m.getData().value);
});
model.getData().value ++;
model.fire(); // console prints '4'

getConfigModel(){bcdui.core.DataProvider}

component/grid/gridCreate.js, line 3459
Returns:
Type Description
bcdui.core.DataProvider configuration model of the grid
A getter for the document produced by the transformation chain.
Returns:
Type Description
* The output of the last transfomration in the chain if it does not produce HTML (output="html").
Name Type Description
name String
Returns:
Type Description
bcdui.core.DataProvider returns the parameter of the given name

getEnhancedConfiguration(){bcdui.core.DataProvider}

component/grid/gridCreate.js, line 3467
Returns:
Type Description
bcdui.core.DataProvider Enhanced configuration model of the grid
Returns:
Type Description
Array.<bcdui.core.Status> Returns all statuses indicating a failure
Getter for the name of the data provider. This name is for example used to set parameters names of a bcdui.core.TransformationChain.
Returns:
Type Description
string The name of the data provider. This name should be unique within the scope it is used and is usually not globally unique (as the id).
Getter for the primary model of the chain. The first transformation of the chain takes a document as input. This document comes from the primary model.
Returns:
Type Description
bcdui.core.DataProvider The model the first transformation in the chain is running on.

inherited getReadyStatus(){Status}

The ready status for the transformation chain is reached as soon as all transformations are finished.

The status transitions of the class are as follows:

Initialized All variables have been initialized.
  
Loading Start loading chain document.
  
ChainLoaded The chain document has been loaded. Start loading chain stylesheets.
  
WaitingForParameters Chain stylesheets loaded. Waiting for parameter data providers (execute).
  
Transforming The chain stylesheets are running.
  
Transformed The output has been generated. (ready)

Returns:
Type Description
Status The transformed status.
Getter for the status of this object. See bcdui.core.status for possible return values.
Returns:
Type Description
bcdui.core.Status The current status.
Return the target html element where the renderer places its output
Tests if the object has reached a failure status. These status codes are returned by the "getFailedStatus" method.
Returns:
Type Description
boolean True, if the object's process has failed.
True, if DataProvider is ready and there are no uncommitted write transactions, see isReady() and fire().
Returns:
Type Description
boolean
Tests if the current state is the readyStatus. This status is the same status as returned by "getReadyStatus".
Returns:
Type Description
boolean True, if the object is ready.

jumpToError()

component/grid/gridCreate.js, line 3292
Jumps to the first error

jumpToRow()

component/grid/gridCreate.js, line 3313
Jumps to given row/col

inherited onceReady(listenerObject)

Name Type Description
listenerObject function | OnceReadyParam Either a function to be called on ready status (i.e. onSuccess) or a parameter map OnceReadyParam. To listen for other states see addStatusListener()
Example
myModel.onceReady({onSuccess: myCallback, executeIfNotReady: true})

inherited onChange(listenerObject, trackingXPath)

Name Type Description
listenerObject function | OnChangeParam Either a function to be called after changes or a parameter map OnChangeParam. Listeners can be removed with removeDataListener()
trackingXPath string optional xPath to monitor to monitor for changes

inherited onReady(listenerObject)

Name Type Description
listenerObject function | OnReadyParam Either a function to be called on ready status (i.e. onSuccess) or a parameter map OnReadyParam. To listen for other states see addStatusListener()
Example
myModel.onReady({onSuccess: function(){ console.log("ready") }, executeIfNotReady: true, onlyFuture: true})
Convenience method for debugging showing data in a prompt for copy-and-paste

inherited query(xPath, fillParams)

Reads a single node from a given xPath
Name Type Description
xPath string xPath to query
fillParams Object optional array or object holding the values for the dot placeholders in the xpath. Values with "'" get 'escaped' with a concat operation to avoid bad xpath expressions
Returns:
single node or null if query fails

inherited queryNodes(xPath, fillParams)

Get node list from a given xPath
Name Type Description
xPath string xPath to query
fillParams Object optional array or object holding the values for the dot placeholders in the xpath. Values with "'" get 'escaped' with a concat operation to avoid bad xpath expressions
Returns:
node list or empty list if query fails

inherited read(xPath, fillParams, defaultValue)

Reads the string value from a given xPath (or optionally return default value).
Name Type Description
xPath string xPath pointing to value (can include dot template placeholders which get filled with the given fillParams)
fillParams Object optional array or object holding the values for the dot placeholders in the xpath. Values with "'" get 'escaped' with a concat operation to avoid bad xpath expressions
defaultValue string optional default value in case xPath value does not exist
Returns:
text value stored at xPath (or null if no text was found and no defaultValue supplied)
Start the loading process of the stylesheets and executes the transformations again.

inherited remove(xPath, fillParams, fire)

Deletes data at a given xPath from the model
Name Type Default Description
xPath string xPath pointing to the value
fillParams Object optional array or object holding the values for the dot placeholders in the xpath. Values with "'" get 'escaped' with a concat operation to avoid bad xpath expressions
fire boolean false optional if true a fire is triggered to notify data modification listener

inherited removeDataListener(listenerObject)

Name Type Description
listenerObject string | function | RemoveDataListenerParam Either a listener function or id or a parameter map RemoveDataListenerParam. Listeners are added with onChange()

inherited removeStatusListener(args)

Name Type Description
args function | StatusListener | RemoveStatusListenerParam The listener to be removed. This can either be a function or a StatusListener or a parameter map RemoveStatusListenerParam.

save()

component/grid/gridCreate.js, line 3364
Save the modified data to the database
Sends the current data to the original URL
Serialize dataprovider's data if available
Returns:
String containing the serialized data

inherited setPrimaryModel(primaryModel)

Adds a new data provider to the list which becomes the new primary model of the transformation chain.
Name Type Description
primaryModel bcdui.core.DataProvider the new primary model of the transformation chain.
Name Type Description
args Status

inherited setTargetHtml(targetHtmlElement)

Sets the target html element where the renderer places its output
Name Type Description
targetHtmlElement HtmlElement target html element
Returns:
Type Description
String String representation of the chain.

inherited write(xPath, fillParams, value, fire)

Set a value to on a certain xPath and create the xPath where necessary. This combines Element.evaluate() for a single node with creating the path where necessary. It will prefer extending an existing start-part over creating a second one. After the operation the xPath (with the optional value) is guaranteed to exist (pre-existing or created or extended) and the addressed node is returned.
Name Type Default Description
xPath string xPath pointing to the node which is set to the value value or plain xPath to be created if not there. It tries to reuse all matching parts that are already there. If you provide for example "/n:Root/n:MyElem/@attr2" and there is already "/n:Root/n:MyElem/@attr1", then "/n:Root/n:MyElem" will be "re-used" and get an additional attribute attr2. Many expressions are allowed, for example "/n:Root/n:MyElem[@attr1='attr1Value']/n:SubElem" is also ok. By nature, some xPath expressions are not allowed, for example using '//' or "/n:Root/n:MyElem/[@attr1 or @attr2]/n:SubElem" is obviously not unambiguous enough and will throw an error. This method is Wrs aware, use for example '/wrs:Wrs/wrs:Data/wrs:*[2]/wrs:C[3]' as xPath and it will turn wrs:R[wrs:C] into wrs:M[wrs:C and wrs:O], see Wrs format. (can include dot template placeholders which get filled with the given fillParams)
fillParams Object optional array or object holding the values for the dot placeholders in the xpath. Values with "'" get 'escaped' with a concat operation to avoid bad xpath expressions Example: bcdui.wkModels.guiStatus.write("/guiStatus:Status/guiStatus:ClientSettings/guiStatus:Test[@caption='{{=it[0]}}' and @caption2='{{=it[1]}}']", ["china's republic", "drag\"n drop"])
value string optional Optional value which should be written, for example to "/n:Root/n:MyElem/@attr" or with "/n:Root/n:MyElem" as the element's text content. If not provided, the xPath contains all values like in "/n:Root/n:MyElem[@attr='a' and @attr1='b']" or needs none like "/n:Root/n:MyElem"
fire boolean false optional If true a fire is triggered to inform data modification listeners
Returns:
The xPath's node or null if dataProvider isn't ready