# Data Table Custom Query

{% hint style="info" %}
**Block Information**

Available in: Page Flow

Toolbox Category: Widget - Data Table

Block Type: [Regular](/app-editor/page-flow/block-anatomy.md#regular-block)
{% endhint %}

The **`Data Table Custom Query`** block allows you to use a custom [Database Query](/app-editor/data/database-queries.md) for the [Data Table](/app-editor/page-editor/built-in-elements/data-table.md) widget.&#x20;

<div align="left"><figure><img src="/files/RHWan3BF65ECXs91SO2b" alt="" width="281"><figcaption><p>Data Table Custom Query block</p></figcaption></figure></div>

Normally the [Data Table](/app-editor/page-editor/built-in-elements/data-table.md) widget reads the [Database Table](/app-editor/data/database-tables.md) without any match criteria or sorting rule. This block allows you to use a custom [Database Query](/app-editor/data/database-queries.md) with matching criteria and/or sorting rules.

The block consists of the following (from top to bottom):

* *Data Table*: [Selectable Input](/app-editor/page-flow/block-anatomy.md#selectable-input) to choose the [Data Table](/app-editor/page-editor/built-in-elements/data-table.md) widget from your page.
* *Query Name*: a [Value Parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) that accepts a [*text*](/app-editor/page-flow/references/value-types.md) value representing the name of the [Database Query](/app-editor/data/database-queries.md) to use.&#x20;
* *Input Params*: a [Value Parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) that accepts a [*list*](/app-editor/page-flow/references/value-types.md) value containing the matching criteria values for the various inputs used by the selected [Database Query](/app-editor/data/database-queries.md) .
* *Per Page*: a [Value Parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) that accepts a [*numeric*](/app-editor/page-flow/references/value-types.md) value that specifies the number of records to load and display per page.

{% hint style="danger" %}
NOTE:

* To enable the functionality of this block, ensure that the [Custom Query setting](/app-editor/page-editor/built-in-elements/data-table.md#custom-query) of the [Data Table](/app-editor/page-editor/built-in-elements/data-table.md) widget is activated.
* The *Query Name* [value parameter](/app-editor/page-flow/block-anatomy.md#value-parameters) needs to point to a valid [Database Query](/app-editor/data/database-queries.md) defined in the associated [Database Table](/app-editor/data/database-tables.md).
* The [Data Table Refresh](/app-editor/page-flow/toolbox-blocks/data-table-refresh.md) block needs to follow this block for the [Data Table](/app-editor/page-editor/built-in-elements/data-table.md) widget to load and display records.
  {% endhint %}

***

## Usage Example

The image below shows an example of the Data Table Custom Query block where the [Database Query](/app-editor/data/database-queries.md) named *Q1* is used. A list containing two items is used as the matching criteria (via *Input Params)*. The number of records per page is set to *10*.

As previously mentioned, it's important to place a [Data Table Refresh](/app-editor/page-flow/toolbox-blocks/data-table-refresh.md) block after this one to ensure that the [Data Table](/app-editor/page-editor/built-in-elements/data-table.md) widget loads and presents the records. This is demonstrated in the example as well.

<div align="left"><figure><img src="/files/cgyejfO7pgDTo5GeNXPi" alt=""><figcaption><p>Example of Data Table Custom Query block</p></figcaption></figure></div>


---

# Agent Instructions: 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:

```
GET https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-table-custom-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
