> For the complete documentation index, see [llms.txt](https://docs.dikesoft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dikesoft.com/fundamentals/datasource.md).

# DataSource

## Live examples

{% hint style="success" %}
[In-Memory DataSource](https://demos.dikesoft.com/dk-grid/datasource/in-memory) live example.
{% endhint %}

{% hint style="success" %}
[Custom DataSource](https://demos.dikesoft.com/dk-grid/datasource/custom) live example.
{% endhint %}

## Specifying data

Every DikeGrid instance accepts data from an <mark style="color:green;">`Array`</mark>, <mark style="color:green;">`Observable< Array>`</mark>, a <mark style="color:green;">`DikeGridDataSource`</mark>, or simply a <mark style="color:green;">`DataSource`</mark>.

{% hint style="info" %}
Remember, the <mark style="color:green;">`DataSource`</mark> definition is an <mark style="color:blue;">`abstract`</mark> class with two methods: `connect()` and `disconnect()`. Therefore, you can provide an instance of a class that derives from the <mark style="color:green;">`DataSource`</mark> class.
{% endhint %}

Depending on the data you provide, there are two types of DataSource: an **In-Memory** DataSource and a **Custom** DataSource.

## Wrapping data entries

It does not matter how you provide your data set. The DikeGrid will **wrap** every data entry in a <mark style="color:green;">`DikeGridDataRowEntry`</mark> instance.

The <mark style="color:green;">`DikeGridDataRowEntry`</mark> wrapper helps to know several features during execution, for instance, when the user modifies a data row or when it is selected, the row status, among others.

{% hint style="success" %}
For further details, see the [<mark style="color:green;">`DikeGridDataRowEntry`</mark>](/reference/classes/rows.md#dikegriddatarowentry-less-than-t-greater-than) definition.
{% endhint %}

Once the DikeGrid **receives** and **wraps** the data, it assigns and emits a **unique id**. You can get this id by listening to the `dataDeliveryIdChange` event.

{% hint style="info" %}
Indeed, a **DikeGrid** instance will send a **unique id** every time you provide a new set of entries. It means that you can have an **Observable** or a <mark style="color:green;">`DikeGridDataSource`</mark>, and if you change the entries set, the DikeGrid will wrap these new entries.
{% endhint %}

Let us listen to the `dataDeliveryIdChange` event:

{% tabs %}
{% tab title="in-memory-data-source.component.html" %}

```markup
<dike-grid id="grid-in-memory-datasource" height="650px" #grid="dkgGrid"
    (dataDeliveryIdChange)="onDataDeliveryIdChange($event)">
</dike-grid>
```

{% endtab %}

{% tab title="in-memory-data-source.component.ts" %}

```typescript
onDataDeliveryIdChange(id: string): void {
  console.log(`Data delivery id: ${id}`);
}
```

{% endtab %}
{% endtabs %}

Open your **dev console** to see the emitted id.

{% hint style="info" %}
The DikeGrid internally creates a <mark style="color:green;">`DikeGridDataSource`</mark> instance to wrap every data entry.
{% endhint %}

{% hint style="warning" %}
Be aware that every time a DikeGrid instance wraps the provided entries, it **resets** the **edition** and **selection** operations. It means that the DikeGrid removes the history of changes and deselects rows.
{% endhint %}

### Row Ids

The DikeGrid sets a **unique id** number for every **row** during the wrapping operation. This id number is a consecutive number starting at the **zero number**.

You can open any live example, go to the [Floating Configuration Panel](/overview.md#floating-configuration-panel), scroll to the **Rows** section and mark the **Row Id** checkbox.

![Floating Configuration Panel - Rows](/files/WOJ84AArmFXF7YmOPsNs)

![Row Ids](/files/NRE3mh9zmWdn3xvgpjpT)

### Timestamp / Row status

Other values that the DikeGrid creates and assigns to every row are the **timestamp** and the initial **row status**.

The timestamp corresponds to the row **creation** time and the row status to the <mark style="color:red;">`Read`</mark> value. The <mark style="color:red;">`Read`</mark> value means that the user has not modified the row.

{% hint style="info" %}
The DikeGrid uses the row status and the timestamp properties to manage the edition operations. See the [Row Edition](/editing/row-edition.md) section.
{% endhint %}
