Class: DataManager

DataView.DataManager

calc/dataManager.js, line 518

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

calc/dataManager.js, line 876

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.

calc/dataManager.js, line 945

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.

calc/dataManager.js, line 954

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.

calc/dataManager.js, line 914

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.

calc/dataManager.js, line 805

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.
calc/dataManager.js, line 867

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.

calc/dataManager.js, line 895

getCalculatedFields()

Gets an array that contains all the calculated field objects.

calc/dataManager.js, line 904

getCalculatedFieldValue(name)

Gets the value of a specified calculated field.

Parameters:
Name Type Description
name string

The name of the calculated field.

calc/dataManager.js, line 589

getGroup(groupPath)

Gets the child group path.

Parameters:
Name Type Description
groupPath Array

An array which indicate the path of the group.

calc/dataManager.js, line 552

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.

calc/dataManager.js, line 563

getItems()

Gets all the view items in the collection.

calc/dataManager.js, line 572

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.

calc/dataManager.js, line 697

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.

calc/dataManager.js, line 924

isCalculatedColumn(column)

Checks whether the column is an existing calculated column.

Parameters:
Name Type Description
column string

The column name to test.

calc/dataManager.js, line 1017

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
    }
}
calc/dataManager.js, line 989

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.
calc/dataManager.js, line 977

isRefreshSuspended()

Checks whether the refreshing of the collection is suspended.

calc/dataManager.js, line 935

reCalculate()

Recalculates all the calculating nodes in the collection, including all calculated columns or fields.

calc/dataManager.js, line 819

refresh()

Refreshes the collection to the latest state.

calc/dataManager.js, line 886

removeCalculatedField(name)

Removes the calculated field from the collection.

Parameters:
Name Type Description
name string

The name of the calculated field to be removed.

calc/dataManager.js, line 770

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.

calc/dataManager.js, line 1127

removeEmptyGroup()

clear old group structure

calc/dataManager.js, line 968

resumeRefresh()

Resumes refreshing the collection.

calc/dataManager.js, line 961

suspendRefresh()

Suspends refreshing the collection.

calc/dataManager.js, line 603

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.

calc/dataManager.js, line 1663

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.
calc/dataManager.js, line 1680

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.
calc/dataManager.js, line 1672

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.

Returns: {*} The converted value.