# GC.Spread.Sheets.DataRange.IDataProvider

## Content

# Interface: IDataProvider

[Sheets](../modules/GC.Spread.Sheets).[DataRange](../modules/GC.Spread.Sheets.DataRange).IDataProvider

## Table of contents

### Properties

- [host](GC.Spread.Sheets.DataRange.IDataProvider#host)

### Methods

- [fromJSON](GC.Spread.Sheets.DataRange.IDataProvider#fromjson)
- [getSpans](GC.Spread.Sheets.DataRange.IDataProvider#getspans)
- [getStyle](GC.Spread.Sheets.DataRange.IDataProvider#getstyle)
- [getValue](GC.Spread.Sheets.DataRange.IDataProvider#getvalue)
- [onClear](GC.Spread.Sheets.DataRange.IDataProvider#onclear)
- [onColumnChange](GC.Spread.Sheets.DataRange.IDataProvider#oncolumnchange)
- [onContextMenu](GC.Spread.Sheets.DataRange.IDataProvider#oncontextmenu)
- [onCopy](GC.Spread.Sheets.DataRange.IDataProvider#oncopy)
- [onDestroy](GC.Spread.Sheets.DataRange.IDataProvider#ondestroy)
- [onDoubleClick](GC.Spread.Sheets.DataRange.IDataProvider#ondoubleclick)
- [onKeyDown](GC.Spread.Sheets.DataRange.IDataProvider#onkeydown)
- [onKeyUp](GC.Spread.Sheets.DataRange.IDataProvider#onkeyup)
- [onMouseDown](GC.Spread.Sheets.DataRange.IDataProvider#onmousedown)
- [onMouseMove](GC.Spread.Sheets.DataRange.IDataProvider#onmousemove)
- [onMouseUp](GC.Spread.Sheets.DataRange.IDataProvider#onmouseup)
- [onMouseWheel](GC.Spread.Sheets.DataRange.IDataProvider#onmousewheel)
- [onRowChange](GC.Spread.Sheets.DataRange.IDataProvider#onrowchange)
- [setValue](GC.Spread.Sheets.DataRange.IDataProvider#setvalue)
- [toJSON](GC.Spread.Sheets.DataRange.IDataProvider#tojson)
- [undo](GC.Spread.Sheets.DataRange.IDataProvider#undo)

## Properties

### <a id="host" name="host"></a> host

• **host**: [`DataRange`](../classes/GC.Spread.Sheets.DataRange.DataRange)

The data provider host.

## Methods

### <a id="fromjson" name="fromjson"></a> fromJSON

▸ `Optional` **fromJSON**(`options`): `void`

Implement this hook to handle the deserialization.

#### Parameters

| Name | Type |
| :------ | :------ |
| `options` | `Object` |
| `options.typeName` | `string` |

#### Returns

`void`

___

### <a id="getspans" name="getspans"></a> getSpans

▸ `Optional` **getSpans**(`row`, `col`, `rowCount`, `colCount`): [`Range`](../classes/GC.Spread.Sheets.Range)[]

Implement this hook to provide spans to data range cells. The `row`, `col`, `rowCount` and `colCount` parameters are based on the data range axis.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `rowCount` | `number` |
| `colCount` | `number` |

#### Returns

[`Range`](../classes/GC.Spread.Sheets.Range)[]

___

### <a id="getstyle" name="getstyle"></a> getStyle

▸ `Optional` **getStyle**(`row`, `col`): [`Style`](../classes/GC.Spread.Sheets.Style)

Implement this hook to provide styles to data range cells. The `row` and `col` parameters are based on the data range axis. It should return the style as `GC.Spread.Sheets.Style`, otherwise, means fail to get style from data provider, so it will continue to get the style from sheet model.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |

#### Returns

[`Style`](../classes/GC.Spread.Sheets.Style)

___

### <a id="getvalue" name="getvalue"></a> getValue

▸ `Optional` **getValue**(`row`, `col`): `unknown`

Implement this hook to provide values to data range cells. The `row` and `col` parameters are based on the data range axis. If returns `undefined`, it means fail to get value from data provider, so it will continue to get the value from sheet model.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |

#### Returns

`unknown`

___

### <a id="onclear" name="onclear"></a> onClear

▸ `Optional` **onClear**(`row`, `col`, `rowCount`, `colCount`, `changes`): `boolean`

Implement this hook to handle the clear contents action. Return `true` means prevent the clear actions from the sheet. Return `false` means prevent to clear data range contents. Default is `false`.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `rowCount` | `number` |
| `colCount` | `number` |
| `changes` | `any`[] |

#### Returns

`boolean`

___

### <a id="oncolumnchange" name="oncolumnchange"></a> onColumnChange

▸ `Optional` **onColumnChange**(`col`, `colCount`, `changeType`, `changes`): `void`

Implement this hook to receive changed columns information. The `col` and `colCount` parameters are based on the data range axis. Post your change into `changes` parameter if you want undo/redo.

#### Parameters

| Name | Type |
| :------ | :------ |
| `col` | `number` |
| `colCount` | `number` |
| `changeType` | ``"delete"`` \| ``"add"`` |
| `changes` | `any`[] |

#### Returns

`void`

___

### <a id="oncontextmenu" name="oncontextmenu"></a> onContextMenu

▸ `Optional` **onContextMenu**(`row`, `col`, `e`): `boolean`

Implement this hook to handle the mouse context menu action. The `row` and `col` parameters are based on the data range axis. Return `true` means prevent the next sheet actions. Default is false.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `e` | `MouseEvent` |

#### Returns

`boolean`

___

### <a id="oncopy" name="oncopy"></a> onCopy

▸ `Optional` **onCopy**(`name`): `boolean` \| { `dataProvider`: [`IDataProvider`](GC.Spread.Sheets.DataRange.IDataProvider) ; `name`: `string`  }

Implement this hook to handle the copy action. Input parameter `name` is copied data range name, need to return a different new data range `name` and a data provider instance. Return `true` means prevent the copy actions from the sheet. Return `false` means prevent to copy data range. Default is `false`.

#### Parameters

| Name | Type |
| :------ | :------ |
| `name` | `string` |

#### Returns

`boolean` \| { `dataProvider`: [`IDataProvider`](GC.Spread.Sheets.DataRange.IDataProvider) ; `name`: `string`  }

___

### <a id="ondestroy" name="ondestroy"></a> onDestroy

▸ `Optional` **onDestroy**(): `void`

Implement this hook to handle the destroy action.

#### Returns

`void`

___

### <a id="ondoubleclick" name="ondoubleclick"></a> onDoubleClick

▸ `Optional` **onDoubleClick**(`row`, `col`, `e`): `boolean`

Implement this hook to handle the mouse double click action. The `row` and `col` parameters are based on the data range axis. Return `true` means prevent the next sheet actions. Default is false.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `e` | `MouseEvent` |

#### Returns

`boolean`

___

### <a id="onkeydown" name="onkeydown"></a> onKeyDown

▸ `Optional` **onKeyDown**(`row`, `col`, `e`): `boolean`

Implement this hook to handle the key down action. The `row` and `col` parameters are based on the data range axis. Return `true` means prevent the next sheet actions. Default is false.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `e` | `KeyboardEvent` |

#### Returns

`boolean`

___

### <a id="onkeyup" name="onkeyup"></a> onKeyUp

▸ `Optional` **onKeyUp**(`row`, `col`, `e`): `boolean`

Implement this hook to handle the key down action. The `row` and `col` parameters are based on the data range axis. Return `true` means prevent the next sheet actions. Default is false.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `e` | `KeyboardEvent` |

#### Returns

`boolean`

___

### <a id="onmousedown" name="onmousedown"></a> onMouseDown

▸ `Optional` **onMouseDown**(`row`, `col`, `e`): `boolean`

Implement this hook to handle the mouse down action. The `row` and `col` parameters are based on the data range axis. Return `true` means prevent the next sheet actions. Default is false.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `e` | `MouseEvent` |

#### Returns

`boolean`

___

### <a id="onmousemove" name="onmousemove"></a> onMouseMove

▸ `Optional` **onMouseMove**(`row`, `col`, `e`): `boolean`

Implement this hook to handle the mouse move action. The `row` and `col` parameters are based on the data range axis. Return `true` means prevent the next sheet actions. Default is false.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `e` | `MouseEvent` |

#### Returns

`boolean`

___

### <a id="onmouseup" name="onmouseup"></a> onMouseUp

▸ `Optional` **onMouseUp**(`row`, `col`, `e`): `boolean`

Implement this hook to handle the mouse up action. The `row` and `col` parameters are based on the data range axis. Return `true` means prevent the next sheet actions. Default is false.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `e` | `MouseEvent` |

#### Returns

`boolean`

___

### <a id="onmousewheel" name="onmousewheel"></a> onMouseWheel

▸ `Optional` **onMouseWheel**(`deltaX`, `deltaY`, `e`): `boolean`

Implement this hook to handle the mouse wheel action. Return `true` means prevent the next sheet actions. Default is false.

#### Parameters

| Name | Type |
| :------ | :------ |
| `deltaX` | `number` |
| `deltaY` | `number` |
| `e` | `MouseEvent` |

#### Returns

`boolean`

___

### <a id="onrowchange" name="onrowchange"></a> onRowChange

▸ `Optional` **onRowChange**(`row`, `rowCount`, `changeType`, `changes`): `void`

Implement this hook to receive changed rows information. The `row` and `rowCount` parameters are based on the data range axis. Post your change into `changes` parameter if you want undo/redo.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `rowCount` | `number` |
| `changeType` | ``"delete"`` \| ``"add"`` |
| `changes` | `any`[] |

#### Returns

`void`

___

### <a id="setvalue" name="setvalue"></a> setValue

▸ `Optional` **setValue**(`row`, `col`, `value`, `changes`): `boolean`

Implement this hook to receive the changed values from data range. The `row` and `col` parameters are based on the data range axis. Post your change into `changes` parameter if you want undo/redo. If returns `true`, it means set value successfully to data provider, so it will prevent to set the value to sheet model.

#### Parameters

| Name | Type |
| :------ | :------ |
| `row` | `number` |
| `col` | `number` |
| `value` | `unknown` |
| `changes` | `any`[] |

#### Returns

`boolean`

___

### <a id="tojson" name="tojson"></a> toJSON

▸ `Optional` **toJSON**(): `Object`

Implement this hook to handle the serialization.

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `typeName` | `string` |

___

### <a id="undo" name="undo"></a> undo

▸ `Optional` **undo**(`change`): `void`

Implement this hook to handle the undo action. Input parameter `change` is the user created in the corresponding hooks.

#### Parameters

| Name | Type |
| :------ | :------ |
| `change` | `any` |

#### Returns

`void`
