np-table Table

A configuration-driven table that dynamically generates the table through columns, simple to use and highly extensible.

Basic Usage

The table is dynamically generated by configuring columns through option, and data is fetched through api.fetch.

浏览器不支持,请手动复制 basic.en.vue

Component Configuration

Props

PropDescriptionTypeDefault
optionConfigurationTableOption-

Methods

Get the table instance through ref, then call the following imperative methods. See Imperative Methods for details.

MethodDescriptionType
reloadReload the data, resetting to the first page() => Promise<void>
refreshRefresh the data of the current page() => Promise<void>
paramsBound query params, passed to api.fetch as queryParamsRecord<string, any>

Types

The component exports the following type definitions:

import type {
  TableOption,
  TableColumn,
  TableFilter,
  TableSearchOption,
  NpTableInst,
} from 'naive-plus'

TableOption

PropDescriptionTypeDefault
columnsTable columnsArray<TableColumn>-
apiData API{ fetch: (pageParams, otherParams) => Promise<{ items, itemCount? }> }-
propsTable props, passed through to n-data-table. To prevent the table's internal vertical scroll from covering page content, scroll-related configs like maxHeight, flexHeight, and virtualScroll will be ignoredobject-
paginationPagination config; set to false to disable paginationfalse / PaginationConfig-
filtersFilter configArray<TableFilter>-
searchSearch config; hidden when omitted or falsefalse / TableSearchOption-
slotsSlot config, takes precedence over the same-named component slotsTableSlotOption-

TableColumn

PropDescriptionTypeDefault
keyColumn field namestring-
labelColumn titlestring-
renderCustom render function(rowData, rowIndex) => VNode-
propsColumn props passed through to n-data-table (e.g. width, minWidth, fixed)object-
displayWhether to display the column in the table; false hides it entirely (often for form-only fields)booleantrue
formPropsForm field config, see CRUDobject-