Initializes a new instance of DataManager.
Parameters:
Name | Type | Description |
---|---|---|
sourceCollection |
Array |
The data source array. |
columnDefs |
Array |
A array of object which are the optional DataViews column definitions. |
Properties:
Name | Type | Argument | Description |
---|---|---|---|
sourceCollection |
Array | The data source array. This property is read-only. |
|
itemCount |
Number | The item count. This property is read-only. |
|
expandedItemCount |
Number | The expanded item count, always less than item count. This property is read-only. |
|
collectionChanged |
Event | The event for the changing data collection. |
|
filterExpression |
string | GC.Spread.Views.DataView.DataManager#filterCallback | The formula string applied to the filter. |
|
filterDescriptors |
Array |
<nullable> |
An array of GC.Spread.Views.DataView.DataManager.filterDescriptor or an array of string that contains the filter descriptors. |
sortDescriptors |
Array |
<nullable> |
An array of GC.Spread.Views.DataView.DataManager.sortDescriptor or an array of string that contains the sort descriptors. |
isSortStable |
boolean | The flag to use a stable sort. This may impact the sort performance. |
|
groupDescriptors |
Array |
<nullable> |
An array of GC.Spread.Views.DataView.DataManager.groupDescriptor or an array of string that contains the group descriptors. |
groups |
Array |
<nullable> |
An array of GC.Spread.Views.DataView.DataManager.DataManagerGroup that contains data manager groups in the first level in the group tree. |
rootGroup |
GC.Spread.Views.DataView.DataManager.DataManagerGroup |
<nullable> |
A dummy root group that contains the group tree. |
hierarchyDescriptor |
GC.Spread.Views.DataView.DataManager.hierarchyDescriptor |
<nullable> |
A hierarchy descriptor object. |
nodes |
Array |
<nullable> |
An array of GC.Spread.Views.DataView.DataManager.DataManagerNode that contains data manager nodes in the first level in the node tree. |
rootNode |
GC.Spread.Views.DataView.DataManager.DataManagerNode |
<nullable> |
A dummy root node that contains the node tree. |
isHierarchical |
boolean | A flag that indicates whether the collection is hierarchical. |
|
pageController |
GC.Spread.Views.DataView.DataManager.pageController |
<nullable> |
A controller used to navigate between pages when paging component used. |
Classes
Methods
addCalculatedField(name, formula)
Adds a calculated field to the collection.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
The name of the calculated field. |
formula |
string |
The formula of the calculated field. |
editCalculatedColumn(column, newFormula)
Sets a new formula in the specified calculated column.
Parameters:
Name | Type | Description |
---|---|---|
column |
string |
The name of the calculated column. |
newFormula |
string |
nullable
The string of the new formula. |
editCalculatedField(name, newFormula)
Sets a new formula in the specified calculated field.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
The name of the calculated field. |
newFormula |
string |
nullable
The string of the new formula. |
evaluate(formula, groupPath, hierarchyPath)
Evaluates the formula with the specified evaluate context.
Parameters:
Name | Type | Description |
---|---|---|
formula |
string |
The formula to be evaluated. |
groupPath |
Array.<Number> |
nullable
The group path as the evaluating context. |
hierarchyPath |
Array.<Number> |
nullable
The hierarchy path as the evaluating context. |
filter(expression){Object}
Filters the data items using the given expression.
Parameters:
Name | Type | Description |
---|---|---|
expression |
string |
Filtering condition expression. |
Returns: {Object} The filter object that supports writing the filter.
getCalculatedColumnValues(name)
Gets an array that contains all the calculated results of the specified calculated column.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
The name of the calculated column. |
getCalculatedFields()
Gets an array that contains all the calculated field objects.
getCalculatedFieldValue(name)
Gets the value of a specified calculated field.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
The name of the calculated field. |
getGroup(groupPath)
Gets the child group path.
Parameters:
Name | Type | Description |
---|---|---|
groupPath |
Array |
An array which indicate the path of the group. |
getItem(viewIndex, getAllInGroup, getAllInTree)
Gets the row item object at the specified view row index.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
viewIndex |
Number |
The row index in the view. |
|
getAllInGroup |
boolean | false |
optional
If false, item in collapsed group is not counted. |
getAllInTree |
boolean | false |
optional
If false, item in collapsed tree node is not counted. |
getItems()
Gets all the view items in the collection.
getNode(groupPath, nodePath)
Gets the child group or node by path.
Parameters:
Name | Type | Description |
---|---|---|
groupPath |
Array |
An array which indicate the path of the group. |
nodePath |
Array |
An array which indicate the path of the node. |
insertDataItems(dataItems, insertAt)
Adds new data items to the source collection at the specified row index in the source, and refreshes DataManager.
Parameters:
Name | Type | Description |
---|---|---|
dataItems |
Object | Array |
An Object or an array of objects which are new data items. |
insertAt |
index |
nullable
The row index in the data source to add. The default is the last one. |
isCalculatedColumn(column)
Checks whether the column is an existing calculated column.
Parameters:
Name | Type | Description |
---|---|---|
column |
string |
The column name to test. |
isModifiedRow(sourceIndex){Boolean}
Indicate the row value has been modified or not.
Parameters:
Name | Type | Description |
---|---|---|
sourceIndex |
number |
The index in the data source. |
Returns: {Boolean} True if the value has been modified, otherwise, return false.
Example
//To get the source index, first you can call getItem method from
//DataView instance, then check the result itemInfo object,if the
//itemInfo.item is not null, you can get sourceIndex from it directly,
//otherwise, if itemInfo.group is not null, can get source index
//by calling getSourceRowIndex method from that DataManagerGroup object,
//if itemInfo.node is not null, can get source index by calling
//getSourceRowIndex method from that DataManagerNode object
var hitInfo = dataView.hitTest(mouseEvent);
if(hitInfo){
var rowId = dataView.getRowId(hitInfo);
var itemInfo = dataView.getItem(rowId);
if(itemInfo){
//get source index from itemInfo.item.sourceIndex
}
}
isNewAddedRow(sourceIndex){Boolean}
Indicate the row is new added row or not.
Parameters:
Name | Type | Description |
---|---|---|
sourceIndex |
number |
The index in the data source |
Returns: {Boolean} True if the new is new added row, otherwise, return false.
isRefreshSuspended()
Checks whether the refreshing of the collection is suspended.
reCalculate()
Recalculates all the calculating nodes in the collection, including all calculated columns or fields.
refresh()
Refreshes the collection to the latest state.
removeCalculatedField(name)
Removes the calculated field from the collection.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
The name of the calculated field to be removed. |
removeDataItems(removeAt, count)
Removes data items from the source collection at the specified source row index.
Parameters:
Name | Type | Description |
---|---|---|
removeAt |
Number |
The row index in the source collection. |
count |
Number |
nullable
Number of row to remove. |
removeEmptyGroup()
clear old group structure
resumeRefresh()
Resumes refreshing the collection.
suspendRefresh()
Suspends refreshing the collection.
updateItem(sourceIndex, newItem)
Update one item at the specific index.
Parameters:
Name | Type | Description |
---|---|---|
sourceIndex |
number |
The source index |
newItem |
object |
The new object which will replace the old one. |
Type Definitions
GC.Spread.Views.DataView.DataManager.filterDescriptor
Properties:
Name | Type | Description |
---|---|---|
field |
string | The field the user wants to sort. |
operator |
string | Indicates the filter type, can be 'equal,', 'notEqual', 'greaterThan', 'greaterThanAndEqual', 'lessThan', 'lessThanAndEqual', 'memberOf' or 'notMemberOf'. |
value |
Object | Array | string | number | Value to compare. when using 'memberOf' or 'notMemberOf', the value can be an array (discrete set) or string (continuous set). For example, [1,2,3,4] means only left values equals to 1 or 2 or 3 or 4; '(1, 4]' means only left values larger than 1 and less than or equal to 4. |
GC.Spread.Views.DataView.DataManager.groupDescriptor
GC.Spread.Views.DataView.DataManager.hierarchyDescriptor
GC.Spread.Views.DataView.DataManager.itemArg
Item object used for GC.Spread.Views.DataView.DataManager~filterCallback and GC.Spread.Views.DataView.DataManager~sortCallback
Properties:
Name | Type | Argument | Description |
---|---|---|---|
dataItem |
Object | The data part of the item argument. |
|
calculatedItem |
Object |
<nullable> |
The calculated part of the item argument. |
GC.Spread.Views.DataView.DataManager.pageController
Properties:
Name | Type | Description |
---|---|---|
first |
function | Go to the first page |
previous |
function | Go to the previous page. |
next |
function | Go to the next page. |
last |
function | Go to the last page. |
goToPage |
function | Go to the specific page. the only parameter it expected is the page index. |
getStatus |
function | Returns the current page status which contains pageIndex, pageSize, maxPages and maxItems. |
statusChanged |
Event | Raised when pageController status changed, the args will be the latest status |
GC.Spread.Views.DataView.DataManager.sortDescriptor
Properties:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
field |
string | The field the user wants to sort. |
||
ascending |
boolean |
<optional> <nullable> |
true | Indicates the sort order. The default is true. |
converter |
GC.Spread.Views.DataView.DataManager~sortConverter |
<optional> <nullable> |
The converter callback for sort GC.Spread.Views.DataView.DataManager#sortConverter. |
filterCallback(value){boolean}
This callback is displayed as part of the Requester class. Used to customize the filter.
Parameters:
Name | Type | Description |
---|---|---|
value |
GC.Spread.Views.DataView.DataManager.itemArg |
The row item to filter. |
Returns: {boolean} The filter status.
groupConverter(value){*}
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description |
---|---|---|
value |
* |
The raw value that needs to be grouped. |
Returns: {*} The converted value.
sortConverter(value){*}
This callback is displayed as part of the Requester class.
Parameters:
Name | Type | Description |
---|---|---|
value |
* |
The raw value that needs to be sorted. |