Creates a new instance of DataView.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
container |
HTMLElement |
Container node the grid attached. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data |
Array | Object |
An array of objects for the grid model or a dataSource object, see dataSource definition for details. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config |
Array | Object |
An array of column definitions or a JSON object used to deserialize the grid. If it is an array of column objects, the column object contains the following properties:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutEngine |
Object |
A layoutEngine instance. |
Classes
Methods
staticGC.Spread.Views.DataView.getControlByElement(node){Object}
Gets the instance of DataView which is hosted to the specified node.
Parameters:
Name | Type | Description |
---|---|---|
node |
Element |
An HTML element which is used to host the DataView instance. |
Returns: {Object} A DataView instance.
cancelBatchEdit()
Cancel batch edit and clear changes.
cancelEditing()
Cancels editing the current row.
clearSelection()
Clear selection.
destroy()
Removes the DataView instance from the host and destroys all resources used by the current instance which includes layout engine and group strategy.
formatDataItem(dataItem){Object}
Formats the dataItem based on column formats.
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object |
Object that needs to be formatted. |
Returns: {Object} The formatted object.
getCachedBatchActions()
Get cahced actions which havn't been saved.
getItem(index){GC.Spread.Views.DataView.itemInfo|Array}
Gets item information by given index or row id.
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | string | Array |
The input view index or row id, can be an array. notice that the index is the view index in control. |
Returns: {GC.Spread.Views.DataView.itemInfo|Array} The queried item information.
getLayoutInfo(){GC.Spread.Views.DataView.layoutInfo}
Gets the layout information of the current instance.
Returns: {GC.Spread.Views.DataView.layoutInfo} An object which uses the area name as the key and the layout information as the value.
getRenderInfo(option){GC.Spread.Views.DataView.renderInfoObj}
Gets the render information.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
option |
Object |
An object used to specify the area, horizontal scroll offset, and vertical offset. The object indicates whether the return value contains row render infos.
|
Returns: {GC.Spread.Views.DataView.renderInfoObj} The render information result.
getRowId(hitInfo){string}
Util method, used to get the corresponding row element id from hitInfo
Parameters:
Name | Type | Description |
---|---|---|
hitInfo |
GC.Spread.Views.DataView.hitTestInfoObj |
hit test result, can get this by calling hitTest method |
Returns: {string} row element id
getRowInfoFromId(rowId){object}
Util method, used to get the row info from row id
Parameters:
Name | Type | Description |
---|---|---|
rowId |
string |
the id of the row |
Returns: {object} row info.
getSelections(){Array}
Gets the data of selected rows.
Returns: {Array} The information of selected rows, including data, sourceRow and columns id.
hideLoadingOverlay()
Hide built-in loading overlay
hitTest(e){GC.Spread.Views.DataView.hitTestInfoObj}
Parameters:
Name | Type | Description |
---|---|---|
e |
TouchEvent | MouseEvent |
Returns: {GC.Spread.Views.DataView.hitTestInfoObj} The hit test information.
invalidate(rebuildDOMTree)
Invalidates the entire control.
Parameters:
Name | Type | Description |
---|---|---|
rebuildDOMTree |
boolean |
Whether to rebuild the entire DOM tree. If true, it replaces the old DOM tree with a new one; otherwise, it updates the old DOM tree container and refreshes each layout area. The default value is true. |
refresh(area)
Refreshes the specified part of the grid.
Parameters:
Name | Type | Description |
---|---|---|
area |
string |
The area that needs to be refreshed. |
saveBatchEdit(callback)
Save batch edit changes.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
callback function which will be executed after save all actions to server return results. |
setSelections(sourceRow, columns)
Set selection.
Parameters:
Name | Type | Description |
---|---|---|
sourceRow |
number | Array |
The source row index or source row indexes array of selected row. |
columns |
string | Array |
The column id collection of selected row. It will work if selectionUnit is cell. |
showLoadingOverlay()
Show built-in loading overlay
startEditing(viewIndex, colIndex)
Starts to edit the current row
Parameters:
Name | Type | Description |
---|---|---|
viewIndex |
number | string |
The dataview row viewIndex or id. |
colIndex |
number |
DataView column index. |
stopEditing()
Stops editing the current row and commits the new value.
toJSON(){Object}
Serializes the current instance to a JSON object
Returns: {Object} A JSON object
innerfailedCallback(error)
failedCallback function need to be called after user retrieve/operate data from server by CRUD/batch.
Parameters:
Name | Type | Description |
---|---|---|
error |
Object |
Error information. |
innersuccessCallback(data, dataSourceLength)
successCallback function need to be called after user retrieve/operate data from server by CRUD/batch.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array | Object |
The requested data. When used in batch edit, it is the responses Array of server. |
dataSourceLength |
number |
nullable
Change the length of data, used only in loadRange callback. |
Type Definitions
GC.Spread.Views.DataView.hitTestInfoObjObject
An object used to represent the hitTest result.
Properties:
Name | Type | Argument | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
area |
string | The area name. |
|||||||||||||||||||||||||||||||||
row |
number | The row index, if groupInfo or nodeInfo is not empty, should use row in groupInfo or nodeInfo |
|||||||||||||||||||||||||||||||||
column |
number |
<optional> |
The column index of the row, if groupInfo or nodeInfo is not empty, should use column in groupInfo or nodeInfo |
||||||||||||||||||||||||||||||||
headerInfo |
object |
<optional> |
The headerInfo object. If the area is columnHeader, there is a headerInfo object which contains more details. Properties
|
||||||||||||||||||||||||||||||||
onTreeExpandToggle |
boolean |
<optional> |
Indicates whether this is on the tree expand toggle button. This property only occurs when there is no grouping; otherwise, it is on the groupInfo object. |
||||||||||||||||||||||||||||||||
isHierarchyFooter |
boolean |
<optional> |
Indicates whether this is on the tree footer. This property only occurs when there is no grouping; otherwise, it is on the groupInfo object. |
||||||||||||||||||||||||||||||||
groupInfo |
Object |
<optional> |
The groupInfo object if there are groups. Properties
|
GC.Spread.Views.DataView.itemInfoObject
An object.
Properties:
Name | Type | Description |
---|---|---|
groupArea |
string | The group area. |
group |
DataManagerGroup | The group instance. |
nodeArea |
string | The area of the tree node. |
node |
DataManagerNode | The instance of the tree node. |
item |
Object | The data item of the queried row. |
GC.Spread.Views.DataView.layoutInfoObject
An object that uses the area name as the key and layout information as the value. It can contain arbitrary areas.
Properties:
Name | Type | Description |
---|---|---|
areaName |
GC.Spread.Views.DataView.layoutInfoObj | The area name. |
GC.Spread.Views.DataView.layoutInfoObjObject
Properties:
Name | Type | Description |
---|---|---|
top |
number | The vertical offset between the container's top-left point and the top-left current viewport rectangle. |
left |
number | The horizontal offset between the container's top-left point and the top-left current viewport rectangle. |
height |
number | The height of the current viewport rectangle. |
width |
number | The width of the current viewport rectangle. |
contentHeight |
number | The height of the content area of the current viewport rectangle. |
contentWidth |
number | The width of the content area of the current viewport rectangle. |
GC.Spread.Views.DataView.renderInfoObjObject
An object used to present the render information object of a viewport.
Properties:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
outerDivStyle |
Object | The style object used for the outer div. |
||||||||||||||||||||||||
outerDivCssClass |
Object | The class list used for the outer div. |
||||||||||||||||||||||||
innerDivStyle |
Object | The style object used for the inner div. |
||||||||||||||||||||||||
innerDivTranslate |
Object | The translate object used to set the inner div translation. Properties
|
||||||||||||||||||||||||
renderedRows |
Array.<Object> | The collection of the render rows information. Properties
|
batchCallback(params)
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
The parameters.
|
Callback(params)
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
The parameters.
|
createCallback(params)
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
The parameters.
|
CRUDactionObject
CRUD action
Properties:
Name | Type | Argument | Description |
---|---|---|---|
type |
string | The type of CRUD, could be 'create', 'update' and 'delete'. |
|
dataItem |
Object | The dataItem to operate. When type is update, it is the updated new item. |
|
index |
number |
<optional> |
The dataItem's index in current view. Not exist when type is create. |
oldDataItem |
Object |
<optional> |
The dataItem before update. Only exist when type is update. |
dataSourceObject
Data source object.
Properties:
Name | Type | Argument | Description |
---|---|---|---|
loadRange |
GC.Spread.Views.DataView~loadRangeCallback |
<nullable> |
The loadRange callback, called when dataView needs update.data |
create |
GC.Spread.Views.DataView~createCallback |
<nullable> |
The create callback, called when dataView create a new item. |
update |
GC.Spread.Views.DataView~updateCallback |
<nullable> |
The update callback, called when dataView edit an item. |
delete |
GC.Spread.Views.DataView~deleteCallback |
<nullable> |
The delete callback, called when dataView delete an item. |
batch |
GC.Spread.Views.DataView~batchCallback |
<nullable> |
The batch callback. In batch editing mode, called when user call saveBatchEdit. |
batchEdit |
boolean | Decide whether to use batch edit. when batch edit mode applied, create, update, delete action won't request server data instantly, but will send a batch request after user call saveBatchEdit, and will recover to old status when user call cancelBatchEdit. |
|
serverSideSort |
boolean | Whether to sort in user's server. If was set true, local sort is disabled. |
|
serverSideFilter |
boolean | Whether to filter in user's server. If was set true, local filter is disabled. |
deleteCallback(params)
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
The parameters.
|
formatCallback(args){string}
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object |
The argument the format function will take.
|
Returns: {string} The formatted value.
hierarchyOffsetCallback(node){number}
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description |
---|---|---|
node |
dataManagerNode |
The dataManager node to render. |
Returns: {number} The offset value in pixels.
updateCallback(params)
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
The parameters.
|
updateOverlayStatusCallback(args)
This callback will be called when loading data from remote server if exist, otherwise, the control will call built-in showLoadingOverlay before loading data and call hideLoadingOverlay after loading data.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
args |
object |
The argument the callback function will take.
|
Events
GC.Spread.Views.DataView.#event:collectionChanged
Occurs after data has changed, such as after sorting, filtering, or grouping.
Type:
- object
Properties:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
sender |
Object | The control instance that causes this event to occur. |
||||||
args |
Object | Provides arguments that are useful for the event. Properties
|
columnChanged
Occurs when the user changes the column visibility, pinned option, or column width, or expands or collapses the column group from UI.
Type:
- object
Properties:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sender |
Object | The control instance that causes this event to occur. |
|||||||||||||||
args |
Object | Provides arguments that are useful for the event. Properties
|
columnReorder
Occurs when the user starts dragging the column and before dropping the column in the column header.
Type:
- object
Properties:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sender |
Object | The control instance that fires this event. |
||||||||||||||||||
args |
Object | Provides arguments that are useful for the event. Properties
|
editing
Editing event. The event occurs before editing, once editing has started, before editing has ended, or editing has stopped.
Type:
- object
Properties:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sender |
Object | The control instance that causes this event to occur. |
||||||||||||||||||||||||||||||
args |
Object | Provides arguments that are useful for the event. Properties
|
focusChanged
The focused row changed event.The event fires on GridLayout or HorizontalLayout.
Type:
- object
Properties:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
sender |
Object | The control instance that causes this event to occur. |
|||||||||
args |
Object | Provides arguments that are useful for the event. Properties
|
grouping
Occurs when the user updates groups with UI actions. The event is fired before the actual update happens.
Type:
- object
Properties:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sender |
Object | The control instance that causes this event to occur. |
||||||||||||||||||
args |
Object | Provides arguments that are useful for the event. Properties
|
rowClick
Occurs when clicking the row.
Type:
- object
Properties:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sender |
Object | The control instance that causes this event to occur. |
|||||||||||||||
args |
Object | Provides arguments that are useful for the event. Properties
|
rowDbClick
Occurs when double-clicking the row.
Type:
- object
Properties:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sender |
Object | The control instance that causes this event to occur. |
|||||||||||||||
args |
Object | Provides arguments that are useful for the event. Properties
|
selectionChanged
Occurs when the user changes the selection using UI actions.
Type:
- object
Properties:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
sender |
object | The control instance that causes this event to occur. |
|||||||||
args |
object | Provides arguments that are useful for the event. Properties
|