Version 1
DataManager GrapeCity DataViewsJS Class

DataManager Class

DataManager is responsible to preprocess input dataset before being visualized.

Heirarchy

  • DataManager

Constructors

constructor

  • new DataManager(sourceCollection: any[], columnDefs?: IColumnDef[]): DataManager
  • Initializes a new instance of DataManager.

    memberof

    GC.DataViews.DataView

    constructor

    Parameters

    • sourceCollection: any[]

      The data source array.

    • Optional columnDefs: IColumnDef[]

      A array of object which are the optional DataViews column definitions.

    Returns DataManager

Properties

pageController

pageController: IPageController

A controller used to navigate between pages when paging component used.

Methods

addCalculatedColumn

  • addCalculatedColumn(name: string, formula: string): void
  • Adds calculated column

    Parameters

    • name: string

      The name of new column

    • formula: string

      The formula of the calculated column

    Returns void

addCalculatedField

  • addCalculatedField(name: string, formula: string): void
  • Adds a calculated field to the collection

    Parameters

    • name: string

      The name of the calculated field

    • formula: string

      The formula of the calculated field

    Returns void

addDataColumn

  • addDataColumn(name: string, dataField: string): void
  • Adds data column

    Parameters

    • name: string

      The name of new column

    • dataField: string

      The name of data field

    Returns void

editCalculatedColumn

  • editCalculatedColumn(column: string, newFormula: string): void
  • Sets a new formula in the specified calculated column.

    Parameters

    • column: string

      The name of the calculated column.

    • newFormula: string

      The string of the new formula.

    Returns void

editCalculatedField

  • editCalculatedField(name: string, newFormula: string): boolean
  • Sets a new formula in the specified calculated field.

    Parameters

    • name: string

      The name of the calculated field.

    • newFormula: string

      The string of the new formula.

    Returns boolean

evaluate

  • evaluate(formula: string, groupPath?: number[], hierarchyPath?: number[]): any
  • Evaluates the formula with the specified evaluate context.

    Parameters

    • formula: string

      The formula to be evaluated.

    • Optional groupPath: number[]

      The group path as the evaluating context.

    • Optional hierarchyPath: number[]

      The hierarchy path as the evaluating context.

    Returns any

filter

  • filter(expression: string): any
  • Filters the data items using the given expression.

    Parameters

    • expression: string

      Filtering condition expression.

    Returns any

    The filter object that supports writing the filter.

getCalculatedColumnValues

  • getCalculatedColumnValues(name: string): any[]
  • Gets an array that contains all the calculated results of the specified calculated column.

    Parameters

    • name: string

      The name of the calculated column.

    Returns any[]

getCalculatedFieldValue

  • getCalculatedFieldValue(name: string): any
  • Gets the value of a specified calculated field.

    Parameters

    • name: string

      The name of the calculated field.

    Returns any

getCalculatedFields

  • getCalculatedFields(): object[]
  • Gets an array that contains all the calculated field objects.

    Returns object[]

getGroup

  • Gets the child group path.

    Parameters

    • groupPath: number[]

      An array which indicate the path of the group.

    Returns DataManagerGroup

getItem

  • getItem(viewIndex: number, getAllInGroup?: boolean, getAllInTree?: boolean): IDataItem
  • Gets the row item object at the specified view row index.

    Parameters

    • viewIndex: number

      The row index in the view.

    • Default value getAllInGroup: boolean = false

      If false, item in collapsed group is not counted.

    • Default value getAllInTree: boolean = false

      If false, item in collapsed tree node is not counted.

    Returns IDataItem

getItems

  • getItems(): IDataItem[]
  • Gets all the view items in the collection.

    Returns IDataItem[]

getNode

  • Gets the child group or node by path.

    Parameters

    • groupPath: number[]

      An array which indicate the path of the group.

    • Optional nodePath: number[]

      An array which indicate the path of the node.

    Returns DataManagerGroup | DataManagerNode

insertDataItems

  • insertDataItems(dataItems: any, insertAt?: number): void
  • Adds new data items to the source collection at the specified row index in the source, and refreshes the data manager.

    Parameters

    • dataItems: any

      An Object or an array of objects which are new data items.

    • Optional insertAt: number

      The row index in the data source to add. The default is the last one.

    Returns void

isCalculatedColumn

  • isCalculatedColumn(column: string): boolean
  • Checks whether the column is an existing calculated column.

    Parameters

    • column: string

      The column name to test.

    Returns boolean

isModifiedRow

  • isModifiedRow(sourceIndex: number): boolean
  • Indicate the row value has been modified or not.

    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 } }

    Parameters

    • sourceIndex: number

      The index in the data source.

    Returns boolean

    True if the value has been modified, otherwise, return false.

isNewAddedRow

  • isNewAddedRow(sourceIndex: number): boolean
  • Indicate the row is new added row or not.

    Parameters

    • sourceIndex: number

      The index in the data source

    Returns boolean

    True if the new is new added row, otherwise, return false.

isRefreshSuspended

  • isRefreshSuspended(): boolean
  • Checks whether the refreshing of the collection is suspended.

    Returns boolean

reCalculate

  • reCalculate(): void
  • Recalculates all the calculating nodes in the collection, including all calculated columns or fields.

    Returns void

refresh

  • refresh(force?: boolean): void
  • Refreshes the collection to the latest state.

    Parameters

    • Default value force: boolean = false

    Returns void

removeCalculatedColumn

  • removeCalculatedColumn(name: string): void
  • Remove specified calculated column

    Parameters

    • name: string

      The name of calculated column to remove

    Returns void

removeCalculatedField

  • removeCalculatedField(name: string): void
  • Removes the calculated field from the collection.

    Parameters

    • name: string

      The name of the calculated field to be removed.

    Returns void

removeDataItems

  • removeDataItems(removeAt: number, count?: number): void
  • Removes data items from the source collection at the specified source row index.

    Parameters

    • removeAt: number

      The row index in the source collection.

    • Optional count: number

      Number of row to remove.

    Returns void

removeEmptyGroup

  • removeEmptyGroup(): void
  • clear old group structure

    Returns void

resumeRefresh

  • resumeRefresh(): void
  • Resumes refreshing the collection.

    Returns void

suspendRefresh

  • suspendRefresh(): void
  • Suspends refreshing the collection.

    Returns void

updateItem

  • updateItem(sourceIndex: number, newItem: any): void
  • Update one item at the specific index.

    Parameters

    • sourceIndex: number

      The source index

    • newItem: any

      The new object which will replace the old one.

    Returns void