Interface

# TableDataSource

<div class="rst-class">

forsearch

</div>

Table Data Source

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

The minimal data source for a `DesktopTable</api/user_interface/desktop/desktoptable>`.

Assign an object implementing this interface to `DesktopTable.DataSource<desktoptable.datasource>` and the table stops storing rows of its own: it asks the source for the row count and for the text of the cells it is about to draw, so the cost of a frame depends on the visible cells only, not on the size of the data set.

<span class="title-ref">CellTextAt</span> is called once per visible cell per frame, so it should be a plain lookup. Every other state - selection, row heights, cell styles, tags - stays with the table and is kept per row index. After the underlying data changes, call `DesktopTable.ReloadFromDataSource<desktoptable.reloadfromdatasource>`.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                     | Parameters                                                                              | Returns                            | Shared |
|------------------------------------------|-----------------------------------------------------------------------------------------|------------------------------------|--------|
| `CellTextAt<tabledatasource.celltextat>` | row As `Integer</api/data_types/integer>`, column As `Integer</api/data_types/integer>` | `String</api/data_types/string>`   |        |
| `RowCount<tabledatasource.rowcount>`     |                                                                                         | `Integer</api/data_types/integer>` |        |

## Method descriptions

<div id="tabledatasource.celltextat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TableDataSource.CellTextAt

**CellTextAt**(row As `Integer</api/data_types/integer>`, column As `Integer</api/data_types/integer>`) As `String</api/data_types/string>`

> Text of a cell, 0-based. It is called once per visible cell per frame, so it should be a plain lookup: an array or dictionary access, never a query or a conversion.
>
> This example maps the column index onto the fields of a record:
>
> ``` xojo
> Select Case column
> Case 0
>   Return mRows(row).Name
> Case 1
>   Return mRows(row).City
> End Select
> ```

<div id="tabledatasource.rowcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TableDataSource.RowCount

**RowCount** As `Integer</api/data_types/integer>`

> Number of visible rows. It is asked while drawing and while hit testing, so it should be a field read rather than a computation.
>
> This example returns the size of the record store:
>
> ``` xojo
> ' Called while drawing and while hit testing, so keep it a field read
> Return mRows.Count
> ```

## Compatibility

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

`DesktopTable</api/user_interface/desktop/desktoptable>`, `EditableTableDataSource</api/interfaces/editabletabledatasource>`, `HierarchicalTableDataSource</api/interfaces/hierarchicaltabledatasource>`, `SortableTableDataSource</api/interfaces/sortabletabledatasource>`

</div>
