> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: rows()

# Method package: w

# Method menu location: w --> Table --> rows

# Method Link: https://dev.wix.com/docs/velo/velo-only-apis/$w/table/rows.md

# Method Description:

Sets or gets the table's row data.

Setting the `rows` property sets the data of the table's rows. A table's
 data is stored as an array of objects where each object represents a row
 in the table.

 The objects are composed of `"key":"value"` pairs where:

 + `key` is:
   + A table column **Field Name** if the columns were set in the Editor
     using the **Manage Table** panel.
   + A table column `dataPath` if the columns were set in code
     using the `columns` property.
 + `value` is the value to be placed in that table column for the current row.


 For example, a simple array of table data may look like this:

 ```javascript
 [
   {
     "firstName": "John",
     "lastName": "Doe",
     "email": "john.doe@somedomain.com",
     "image": "http://someImageUrl/john.jpg"
   },
   {
     "firstName": "Jane",
     "lastName": "Doe",
     "email": "jane.doe@somedomain.com",
     "image": "http://someImageUrl/jane.jpg"
   }
 ]
 ```

 If the `rows` array contains objects with values whose keys are not
 table columns, those values do not appear in the table. For example,
 assuming the `rows` array shown above, if the table does not have an
 **email** column, the email values do not appear in the table.

 Set `rows` to an empty array (`[]`) to remove the current rows.

 Getting the `rows` property returns the current list of
 the table's row data. If the table is connected to a dataset, `rows`
 does not include the fields from the dataset items that are not
 connected to table columns.

 To update an individual table row, use the [`updateRow()`](#updateRow)
 function.

 To add or remove individual table rows:

   1. Store the value of the `rows` property in a variable.
   1. Apply standard JavaScript array operators to the rows array.
   1. Reset the `rows` property with the new array.


 To set a table's row data based on a [`query`](https://dev.wix.com/docs/velo/apis/wix-data/query.md)
 you perform using the [`wix-data`](https://dev.wix.com/docs/velo/apis/wix-data/introduction.md) API:

 1. Set the columns of the table in the Editor using the **Manage Table**
    panel or in code using the [`columns`](#columns) property to include
    the collection fields you want to display.
 1. Execute a [`query()`](https://dev.wix.com/docs/velo/apis/wix-data/query.md) using the [`find()`](https://dev.wix.com/docs/velo/apis/wix-data/wix-data-query/find.md)
    function.
 1. Set the tables `rows` to the [`items`](https://dev.wix.com/docs/velo/apis/wix-data/wix-data-query-result/items.md)
    of the query's [results](https://dev.wix.com/docs/velo/apis/wix-data/wix-data-query-result/introduction.md).


 Note that you can optionally add to, remove from, or modify the data
 returned from the query before using it to set the table's row data.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Get a table's row data

```javascript
let tableRows = $w("#myTable").rows;

let value = tableRows[0]["field_name"]; // "field value"
```

## Set a table's row data

```javascript
$w("#myTable").rows = tableRows;
```

## Add a row to a table

```javascript
let rows = $w("#myTable").rows;
rows.push({field_1: "Value1", field_2: "Value2"});
$w("#myTable").rows = rows;

```

## Set a table's row data from an array

```javascript
const myTableData = [
  {"name": "A", "num": 45},
  {"name": "B", "num": 34},
  {"name": "C", "num": 19},
  {"name": "D", "num": 59},
  {"name": "E", "num": 24},
  {"name": "F", "num": 96}
];

// ...

$w("#myTable").rows = myTableData;
```

## Set a table's row data from a query

```javascript
import wixData from 'wix-data';

// ...

wixData.query("myCollection")
  .find()
  .then( (results) => {
    $w("#myTable").rows = results.items;
  } );
```

## Set a table's row data from a query

```javascript
/*
  The collection "myCollection" has the following field IDs:
  - docName: name of the document
  - docDescription: description of the document
  - doc: the document file
 */

import wixData from 'wix-data';

$w.onReady( function () {

  // set the table columns
  $w("#myTable").columns = [
    // the column that shows the document name
    {
      "id": "col1",
      "dataPath": "docName", // matches field ID from collection
      "label": "Name",
      "width": 100,
      "visible": true,
      "type": "string",
    },
    // the column that shows the document description
    {
      "id": "col2",
      "dataPath": "docDescription", // matches field ID from collection
      "label": "Description",
      "width": 100,
      "visible": true,
      "type": "string",
    },
    // the column for downloading the document
    {
      "id": "col3",
      "dataPath": "download", // does not match field ID from collection
      "label": "Download",
      "width": 100,
      "visible": true,
      "type": "richText",
      "linkPath": "doc" // matches field ID from collection
    }
  ];

  // execute query
  wixData.query("myCollection")
    .find()
    .then((results) => {
      // get the query result items
      let tableRows = results.items;

      // add a property and value to serve as link text
      // property key matches third column dataPath above
      tableRows.forEach( (row) => {
        row.download = '<span style="color:blue">Download the doc</span>';
      } );

      // set the table row data
      $w("#myTable").rows = tableRows;
    } );

} );

```

---