> For the complete documentation index, see [llms.txt](https://ghiscoding.gitbook.io/aurelia-slickgrid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ghiscoding.gitbook.io/aurelia-slickgrid/grid-functionalities/providing-grid-data.md).

# Providing data to the grid

### Overview

The data is passed to the grid via the constructor and can also be accessed using the `setData(data)` and `getData()` methods. Data itself can be either an array-like object with a `length` property and an indexer (`data[index]`) or a custom data provider implementing the following interface:

* `getLength()` - returns the number of data items in the set
* `getItem(index)` - returns the item at a given index
* `getItemMetadata(index)` - returns the metadata for the item at a given index (optional)

### Item Metadata

`getItemMetadata` provides a powerful way of specifying additional information about a data item that let the grid customize the appearance and handling of a particular data item. The method should return `null` if the item requires no special handling, or an object in the following general format:

```
{
  // properties describing metadata related to the item (i.e. grid row) itself
  "<property>": value,
  "<property>": value,

  // properties describing metadata related to individual columns
  "columns":  {
    "<column index>":  {
      // metadata indexed by column index
      "<property>": value,
      "<property>": value
    },

    "<column id>":  {
      // metadata indexed by column id
      "<property>": value,
      "<property>": value
    }
  }
}
```

#### Row-level properties

* `cssClasses` (string) - One or more (space-separated) CSS classes to be added to the entire row.
* `focusable` (boolean) - Whether or not any cells in the row can be set as "active".
* `selectable` (boolean) - Whether or not a row or any cells in it can be selected.

#### Column-level properties

* `focusable` (boolean) - Whether or not a cell can be set as "active".
* `selectable` (boolean) - Whether or not a cell can be selected.
* `formatter` (Function) - A custom cell formatter.
* `editor` (Function) - A custom cell editor.
* `colspan` (number|string) - Number of columns this cell will span. Can also contain "\*" to indicate that the cell should span the rest of the row.

#### Order of checks

When looking up a property, the grid checks in the following order:

1. Row-level item metadata.
2. Column-level item metadata by column id.
3. Column-level item metadata by column index.
4. Column definition.
5. Grid options.
6. Grid defaults.

### Examples

See [colspan example](https://ghiscoding.github.io/aurelia-slickgrid-demos/#/slickgrid/example14).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ghiscoding.gitbook.io/aurelia-slickgrid/grid-functionalities/providing-grid-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
