Data List
ListView
Practical Guide
#
Applicable Scenarios适用于从数据源中查询多条数据,并将返回列表循环展示的场景,如查询用户列表。
Basic Features
Data Query, Filtering, Pagination
The Data List Component is one of the core components for obtaining data, enabling quick querying of lists from data models and APIs and rendering them to the page's list, including features such as pagination.
Data Usage and Display
Data List is a data provider, and the data it provides can be used by all business components. The data of Data List can be selected from data tables or bound expressions.
1. Quickly select a data table
Drag components that require data binding into the data container to select its data.

2. Binding Expression
Expressions can be static data or variables. You can connect to built-in data tables and external APIs, etc., via Query, and then bind a query in the expression.
3. Binding APIs (removed in the latest version)
NoteStarting from the v2.30.0 component version, APIs invocation for Data Table has been removed. Please use expressions to select Query for querying APIs.
Parameter Requirements for Calling APIs
- Method input parameters:
- pageNo: Page number (optional)
- pageSize: Page size (optional)
- orderBy: Sort field name (optional). Can be any field in the output parameter 'records'.
- orderType: Sort order (optional). Pass 'asc' for ascending order or 'desc' for descending order.
- Method output parameters:
total: Total number of records (required)
records: An array of objects containing multiple data records. Note: Each object in the array must contain a unique identifier field _id (text type) for the paginator to function properly, such as page turning.
Implementing Dynamic Pagination by Binding query
For data list binding expression scenarios, configure as follows to achieve dynamic pagination effects under these two pagination methods: click-to-load-more and scroll-to-bottom-load-more.
- Add data list:
- Add a data list and switch to the expression scenario.
- Create query:
Select data table
[Triggering Method] Automatically execute when input parameters change
[Page size] bound to the data list's pageSize
$w.listView1.pageSize;
[Page number] bound to the data list's pageNo
$w.listView1.pageNo;
- Create array variable:
- Create event flow:
- Select [Variable Assignment] for the execution action
- Assign content as merge arrays:
[...$w.page.dataset.state.records, ...$w.query1.data.records];
- Chain data pipelines:
query Add event callback
Bind the array variable to the data list expression
$w.page.dataset.state.records;
Enable dynamic pagination
Bind the total data count to the query's total field
$w.query1.data.total;
The following video demonstrates how to bind a query to retrieve data and configure pagination:
Field Query Scope Settings
Data lists, after supporting the v2 query protocol, enable on-demand configuration of field query scopes to improve query performance.
Field Query Scope Settings support the following three methods:
- All Fields: returns all fields, including those from this table and associated tables.
- Current Table Fields: returns all fields of the current table, excluding fields from associated tables. (default setting)
- Custom Query Fields: supports on-demand configuration of main table fields to be returned and whether to return associated table fields.
Property Introduction
External properties received by the component
Property Name | Property Identifier | Type | Description |
---|
列表模板 | template | string | 列表内容样式的预设模板 Example: "simpleList" |
数据源 | dataSourceType | string | 数据源类型选择 Example: "data-model" |
数据模型 | datasource | object | 展示模型数据的数据来源 |
APIs | bindConnectMetadata | object | 展示数据的APIs来源选择 |
表达式 | dataSourceData | array | 数据列表展示的数据,可选择变量。 |
exprToFieldsSchema | string | ||
调用方法 | connectorMethod | object | 展示数据的APIs调用方法选择 |
查询入参 | connectorParams | object | 对APIs调用方法获取的数据进行筛选过滤。支持对象类型,例如 {name:'',value:''} |
数据筛选 | queryCondition | array | 对数据进行筛选过滤 |
排序字段 | orderBy | string | 选取对数据进行排序的字段 |
排序方式 | orderType | string | 设置升序或降序 Example: "asc" |
启用多字段排序 | isSupportMultipleSort | boolean | Example: false |
数据排序 | sorter | array | 可设置数据排序规则,支持拖拽调整排序优先级,数组下标越小优先级越高。绑定数据示例:[{"orderBy":"updatedAt","orderType":"desc"}],升序传值asc,降序传值desc Example: [ { "orderBy": "updatedAt", "orderType": "desc", "label": "更新时间" } ] |
字段查询范围 | selectFieldType | string | 默认查询本表字段 Default value: "main" |
自定义查询字段 | selectFields | array | |
分页方式 | pagination | string | 数据分页样式 Example: "loadMoreButton" |
加载按钮名称 | loadButtonText | string | Example: "加载更多" |
每页条数 | pageSize | number | 设置单次加载的数据条数 Example: 5 |
页码 | pageIndex | number | 初始页码 Example: 1 |
启用动态分页 | enableTotal | boolean | 开启后,可支持动态分页 Example: false |
数据总数 | total | number | 默认为表达式输入的数组长度,请输入数据表实际数据总数。 |
空状态提示 | emptyText | string | 无数据时的提示说明,内容为空时则不显示该提示 Example: "暂无数据" |
加载到底提示 | loadCompletedText | string | 加载全部数据后的提示说明,内容为空时则不显示该提示 Example: "" |
显示加载状态 | isSetLoading | boolean | 是否开启数据列表的加载状态,默认显示 Default value: true |
显示异常状态 | isSetStatus | boolean | 是否开启数据列表的异常状态,默认不显示 |
数据加载状态 | loading | boolean | 开启后会展示数据加载中状态 |
Event Introduction
Events exposed by the component. You can listen to component events to trigger external actions
Event Name | Event Code | Event Output Parameters event.detail | Applicable Scenarios | Description |
---|
查询为空 | queryEmpty | Compatible with all platforms | 数据查询为空时触发 | |
查询成功 | querySuccess | Compatible with all platforms | 数据查询成功时触发 | |
查询失败 | queryFail | object
| Compatible with all platforms | 数据查询失败时触发 |
分页变化 | onPagingChange | object
| Compatible with all platforms | 分页变化 |
Property API
Through the Property API, you can access the internal state and property values of components. You can access internal values using$w.componentId.propertyName
, such as $w.input1.value
. For details, please refer to Property API
Read-only Property Name | Property Identifier | Type | Description |
---|
列表记录 | records | array | 列表记录 |
记录总条数 | total | number | 记录总条数 |
页码 | pageNo | number | 当前页码 |
每页大小 | pageSize | number | 每页大小 |
错误信息 | error | object | 组件内部抛出的错误信息 |
数据源协议版本 | dataSourceVersion | string | 数据源类型为数据模型时,数据列表支持的数据源协议版本 |
Method API
Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName
, such as $w.form1.submit()
Method Name | Method Identifier | Parameters | Method Description |
---|
刷新 | refresh | string 刷新方式 Default value: refreshFromStart Optional values:refreshFromStart(刷新并回到第1页) refreshKeepPage(刷新当前页) | - |
删除单条数据 | deleteOne | string 删除数据的标识 | - |
Application Example
The following example shows the model user list:
1. Add a data containerData sources support data models and APIs.
Thus, the user list query feature is now complete! The full implementation is as follows:
Frequently Asked Questions
When using data container components, must other components be placed inside them?
The Data Container is the core component for page-data interaction, capable of directly querying and displaying data. On our platform, multiple data container components are available, such as ListView, DataView, WdForm, and WdTable.
The Data Container enables deep integration of data and page components. This greatly simplifies data operation processes. In addition to providing data, the Data Container also supports common page interaction features, such as pagination loading, loading status, and error prompts.
When using data containers, if a component relies on data returned by the data container, it is recommended to place the component inside the data container component. For example, to display an image from a specific field in a data detail, it is better to place the component inside the corresponding data container. This way, the data container can automatically handle loading states, loading failures, etc., without needing to worry about rendering timing.
If you only need to use the data container to obtain data without performing UI interactions, you can directly use the Query function to query data.
How to display Chinese labels for common option sets in data containers
Common option sets now support querying values by key. For usage, refer to the documentation: https://cloud.tencent.com/document/product/1301/95807
How do you refresh other components when an event is triggered?
When you need to refresh other components upon an event trigger, bind a variable to the target component's property, for example by referencing this variable in a filter parameter expression. Then change the variable's value in the triggering event to update the corresponding target component's content.
How to Get Selected Row Data When Checkboxes Are Added to the ListView
To obtain the multi-selected data in the data list, you can bind a custom method to the checkbox's change
event. First, create a page array variable, such as selectedIds
. In the custom method, you can process the data based on the selection state:
- When a checkbox is selected, add the current row's data to the
selectedIds
array. - When a checkbox is deselected, remove the current row's data from the
selectedIds
array.
It is recommended to pass the current row's data identifier (such as _id) as a parameter to the custom method when binding it, to facilitate processing the selected row's data.