For vue2 projects, use @94ai/common-ui
LLMs.md

nf-table ​

Data table with search, pagination, column settings, renderers, action bars and virtual scrolling.

Table column settings and resized widths use IndexedDB (the nf-table object store in the common-ui-plus database), restored asynchronously without a localStorage fallback or automatic migration of old caches. Await clearColumnEditCached(), clearDragCached() and the legacy *Cookies* synchronization methods to wait for completion. If IndexedDB is unavailable, the current instance remains usable. Search form field settings use the nf-search-form object store in the same database.

ts
import NfTable from '@94ai-plus/nf-table'
import type { NfTableColumnAttributes, TableSearchEvent } from '@94ai-plus/nf-table'
import '@94ai-plus/nf-table/style.css'

Easy configuration ​

Loading example…
Easy configuration

Data-driven customization ​

Loading example…
Data-driven customization

Custom slots and fixed columns ​

Loading example…
Custom slots and fixed columns

Data with slots ​

Loading example…
Data with slots

Bordered table and nested headers ​

Loading example…
Bordered table and nested headers

Sorting and filtering ​

Loading example…
Sorting and filtering

Expandable rows and tree data ​

Loading example…
Expandable rows and tree data

Virtual table without pagination ​

Loading example…
Virtual table without pagination

Fixed-right action column resizing and indicator bounds ​

Loading example…
Fixed-right action column resizing and indicator bounds

NfTableColumnAttributes ​

parametersDescriptionType
keyUnique identifier for the column; not set prop used as a fallback identifier.string / number
propColumn field path.string
typeSelect a column, ordinal column, or expand a column.selection / index / expand
labelColumn header, also returned by the function.string / Function
attrElement Plus TableColumn public properties.ElTableColumnAttributes
slotCell named slot.string
headerSlotHeader named slot.string
singleHeadMutiColSlotTableColumn slots are nested under a single table header.string
childrenNested header column definitions.NfTableColumnAttributes[]
renderCustomize cells using Vue 3h or VNode.(row, scope) => VNodeChild
labelTooltip / labelTooltipPlacementHeader prompts and location.string
unitData unit suffix.string
options / getOptionsStatic or asynchronous enum mapping; option supports tagType.array / Function
optionsEnum / optionsTagMapping of values to text, label types.object
operationListA function that operates on a button configuration or returns a configuration by row.array / Function
operationSpanCollapse when the number of action buttons exceeds the specified number; 0 by width.number
initHiddenThe initial hidden state of the column.boolean
destroy / destory / showControl column display by configuration.boolean / Function
fit.tagsTags involved in content width estimation.string[]

Attribute ​

parametersDescriptionTypeOptional valueDefault value
dataPopulate table dataRecord<string, any>[]—[]
columnsRender table header json dataNfTableColumnAttributes[]—[]
searchFormAttrsForm attributes, the same as nf-search-form Attributes attributesNfSearchFormAttributes—{}
pageAttrsPagination properties. Omitting total uses front-end paging; passing total uses server-side paging, and the business party returns the current page data according to the request.ElPaginationAttributes—{}
tableAttrsTable attributes, transparent transmission Element Plus Table public properties.ElTableAttributes—{}
searchFormEventsForm events are consistent with nf-search-form component EventsPartial<Record<NfSearchFormEventKey, Function>>—{}
pageEventsPagination events are consistent with el-pagination component EventsPartial<Record<ElPaginationEventKey, Function>>—{}
tableEventsTable events are consistent with el-table component Table EventsPartial<Record<ElTableEventKey, Function>>—{}
actionBarOptListactionBar button renders json dataNfTableActionBtnAttributes[]—[]
operationPropKeyData-driven rendering of cell operation buttons, the prop value of the specified cell is defined as the key of the button operation columnstring—'operation'
alwaysShowPageWhether to always display pagination; virtual tables do not display pagination.boolean—true
calHeightThe fixed window fills the screen (or fills the parent container) and the table automatically calculates the height, which is used to implement fixed-height content scrolling of a window table (content is limited to height and self-scrolling). This is a relatively good table interaction effect.boolean—false
dragCachedWhether to cache column drag width, use IndexedDB.boolean—true
dragIndicatorPaddingLeftFixed the minimum distance (px) between the right column drag indicator line and the left sidenumber—120
dragIndicatorPaddingRightFixed the minimum distance (px) between the right column drag indicator line and the right sidenumber—120
fixedRightDragEnabledWhether to enable the custom drag handle fixed to the right operation columnboolean—false
emptyImageSizeTable empty data spatio-temporal component sizenumber—145
initSearchApiWhether to automatically query during initialization; follow setEasyConf if not passed.booleanIf you don’t pass it on, you will follow it.setEasyConfundefined
pageChangeSearchApiWhether paging changes are automatically queried; if not passed, follow setEasyConf.booleanIf you don’t pass it on, you will follow it.setEasyConfundefined
pageKeysFields used for paginationstring[]-['pageNo', 'pageSize']
setEasyConfEnable simple configuration and provide initialization query, paging query, search layout and row-key default value. Explicit settings take precedence.booleanPlease checkfalse
loadingFunction
loadingTable loadingboolean—false
targetLoading DOM nodes that need to be covered. A DOM object or string can be passed in; if a string is passed in, it will be passed into document.querySelector as a parameter to obtain the corresponding DOM node.HTMLElement—undefined
bodySame as body modifier in v-loading directiveboolean—false
fullscreenSame as fullscreen modifier in v-loading directiveboolean—false
lockSame as the lock modifier in the v-loading directiveboolean—false
textLoading Loading text displayed below the loading iconstring—undefined
spinnerLoading custom loading icon class namestring—undefined
backgroundLoading mask background colorstring—undefined
customClassCustom class name for Loadingstring—undefined
columnEditColumn editing function switch.boolean—false
columnPositionColumn edit button positionstringfree/embed'embed'
showColumnColumn editing initializes the table item field prop collection to be displayed. [] represents displaying all, and can be used in conjunction with initHidden of columns.string[]—undefined
priorityColumn editing cache echo priority, handles the echo relationship between item.initHidden, form.showColumn and IndexedDB.cachestringcached/value'cached'
storageKeyThe IndexedDB cache key set by the table column; multiple instances of the same page should use independent keys.string-nf-table-columns-cached-key-${routeName}
searchFormStorageKeyOptional, the meaning is the same as storageKey. nfSearchForm sets the field cache key. You can also set storageKey in searchFormAttrs.string-nf-search-form-columns-cached-key-${routeName}
checkModeOptional, column editing interactive mode, default drawer (drawer/dialog)stringdialog/drawer'drawer'
columnDisplayBtnClassColumn edit button class namestring—''
columnDisplayBtnIconColumn edit button iconstring—undefined
columnDisplayBtnTypeColumn edit button typestring—'primary'
columnDisplayBtnPlainColumn edit button hollowboolean—true
columnDisplayBtnSizeColumn edit button sizestring—'mini'
columnDisplayBtnRoundColumn edit button rounded cornersboolean—false
columnDisplayBtnCircleColumn edit button circleboolean—false
columnDisplayBtnLoadingColumn edit button Loadingboolean—false
columnDisplayBtnDisabledColumn edit button disabledboolean—false
columnDisplayBtnTextColumn edit button textstring—Follow language pack
columnCheckTitleColumn editing dialog/drawer mode->pop-up box titlestring-Set display fields
columnCheckCancelButtonTextColumn edit dialog/drawer mode cancel button textstring-'Cancel'
columnCheckConfirmButtonTextColumn editing dialog/drawer mode determine button textstring-'OK'
columnCheckBasicFieldDescDefault category titlestring-Follow language pack
columnCheckWidthColumn editing dialog mode->pop-up box widthstring-'600px'
columnCheckModalAppendToBodyColumn editing dialog mode->pop-up mask layer appendToBodyboolean-true
columnCheckModalColumn editing dialog mode -> Whether the pop-up box displays the mask layerboolean-true
columnCheckFullscreenColumn editing dialog mode -> whether the pop-up box is full screenboolean-false
columnCheckTopColumn editing dialog mode->pop-up box Topstring-'15vh'
columnCheckAppendToBodyColumn editing dialog mode->pop-up box appendToBodyboolean-false
columnCheckLockScrollColumn editing dialog mode->Pop-up LockScrollboolean-true
columnCheckCustomClassColumn editing dialog mode->pop-up box CustomClassstring-''
columnCheckCloseOnlickModalColumn editing dialog mode->pop-up box CloseOnlickModalboolean-true
columnCheckCloseOnPressEscapeColumn editing dialog mode->pop-up box CloseOnPressEscapeboolean-true
columnCheckShowCloseColumn editing dialog mode->pop-up box title ShowCloseboolean-true
columnCheckBeforeCloseColumn editing dialog mode->pop-up box beforeCloseFunction-undefined
columnCheckCenterColumn editing dialog mode -> whether the pop-up box is centeredboolean-false
columnCheckDestroyOnCloseColumn editing dialog mode -> popup box destruction whether to delete the sub-domboolean-false
columnCheckTabsColumn editing drawer mode->tab dataITabItem[]--
columnCheckCurrentTabColumn editing drawer mode->Currently displayed tab namestring--
selectEmptyWarningTipsPrompt when the column editing setting field is not emptystring-Please select at least one option
columnCheckSearchPlaceholderColumn editing drawer mode->search box placeholderstring-'Search'
columnCheckFixedLeftDescColumn editing drawer mode -> fixed to left descriptionstring-Follow language pack
columnCheckClearDescColumn editing drawer mode -> clear descriptionstring-Follow language pack
columnCheckNoFixedDescColumn editing drawer mode -> Unfixed descriptionstring-Follow language pack
columnCheckGetCheckedLengthDescColumn editing drawer mode->selected description(length) => string-(length) => 'selected (' + length + ')'
columnCheckGetAllCheckDescColumn editing drawer mode->select all description(length) => string-(length) => 'Select all (' + length + ')
virtualizedEnables virtual scrolling with fixed row height.boolean—false
virtualTableDataVirtual table complete data source; data is used when not set.Record<string, any>[]—undefined
virtualPropsVirtual window configuration: rowHeight/itemSize, height, buffer.object—{}
emptyTextEmpty status text.string—Follow language pack
viewIdentityView or user configuration ID.string—undefined
detectResizeCompatibility properties are retained; container layout is automatically observed by ResizeObserver.boolean—false
drawerPropsTransparent column settings drawer properties.object—{}

Attribute Easy configuration ​

parametersDescriptionTypeOptional valueDefault value
initSearchApitrue———
pageChangeSearchApitrue———
searchFormAttrs.labelWidth80———
searchFormAttrs.columns4———
searchFormAttrs.btnModelinline———
searchFormAttrs.columnEdittrue———
tableAttrs.row-keyid———

Methods ​

method nameDescriptionparameters
clearSelectionUsed for multi-select forms to clear user selections—
toggleRowSelectionUsed for multi-select tables to switch the selected state of a certain row. If the second parameter is used, it is to set whether this row is selected or not (selected is true to select)row, selected
toggleAllSelectionUsed for multi-select tables to switch the selected state of all rows—
toggleRowExpansionUsed for expandable tables and tree tables to switch the expanded state of a row. If the second parameter is used, it is set to expand or not the row (expanded is true to expand)row, expanded
setCurrentRowUsed for single-select tables to set a certain behavior to select a row. If called without parameters, the selected state of the currently highlighted row will be cancelled.row
clearSortUsed to clear the sorting conditions and the data will be restored to its unsorted state.—
clearFilterWhen no parameters are passed in, it is used to clear all filtering conditions, and the data will be restored to an unfiltered state. You can also pass in an array composed of columnKey to clear the filtering conditions of the specified column.columnKey
doLayoutRelayout the Table. This method may need to be called when the Table or its ancestor elements are switched from hidden to displayed—
sortManually sort the Table. The parameter prop attribute specifies the sorting column, and order specifies the sorting order.prop: string, order: string
resetNfSearchFormModelPerform reset manually—
onNfSearchFormValidateManually execute validatecallback: Function
onNfSearchFormSearchPerform a search manually—
onNfSearchFormExportExecute export manually—
getSelectionRows()Get the currently selected row.—

Event ​

event nameDescriptioncallback parameters
tableEventsTable events are consistent with el-table component Table Events—
pageEventsPagination events are consistent with el-pagination component Events—
searchFormEventsForm events are consistent with nf-search-form component Events—
NfTableActionBtnAttributes.eventsactionBtnbar button event—
columns[i].operationList[i].onClickOperation function cell button click event—
changeTabSwitch multiple drawer tabsname
cancelClose drawer tabEvent
searchApiSame as searchFormEvents.onSearch, with slight changes in parameters
fixedColumnDragEndFixed right operation column (custom handle) dragging ends
fieldsChangeThe table shows field changes.columns: string[]
update:showColumnfor v-model:showColumn.columns: string[]
update:actionBarOptListThe value of the action bar control changes.items: NfTableActionBtnAttributes[]
options-errorAsynchronous column option loading failed.(error, prop: string)

Slot ​

NameDescription
appendInsert content after the last row of the table. If you need to infinitely scroll the content of the table, you may need to use this slot. If the table has a total row, this slot will be above the total row.
emptyCustomization when table data is empty
searchBoxCustomized search function above the table
actionBarActionBar function customization in the lower left corner of the table
columnEditCustomized list editing function
paginationCustomization of paging function
btnBoxnf-search-form slot, compatible with ai-search-form extended operation button
columns[i].headerSlotCustomization of header functions for each tableItem
columns[i].slotEach tableItem content function is customized
columns[i].singleHeadMutiColSlotCustomization of nested header functions for each tableItem
searchFormColumnEditDialogTitlenf-search-form list editing function dialog/drawer title
searchFormColumnEditDialogFooternf-search-form list editing function dialog/drawer footer
tableColumnEditDialogTitlenf-table list editing function dialog/drawer title
tableColumnEditDialogFooternf-table list editing function dialog/drawer footer
operationManipulate columns; receives row, column, index, $index.
operationIconColumnCheckCustomize the field setting entry embedded in the operation list header.
NfSearchFormItemOption.slotTransparently transmit search form field slot; receive formData, value, update.

Expose ​

NameTypeDescription
localShowItemsstring[]Column props displayed by column editing
tableColumnsNfTableColumnAttributes[]Render table items
syncLocalShowColumnToCookiesFunctionColumn editing sync component to IndexedDB
syncCookiesToLocalShowColumnFunctionColumn editor synchronizes IndexedDB to component localShowItems
syncCookiesToTableColumnFunctionsyncCookiesToLocalShowColumn
syncShowItemToInitHiddenFunctionshowItems synchronizes props.formOptions[i].initHidden
resetNfSearchFormModelFunctionreset
onNfSearchFormValidateFunctionVerify
onNfSearchFormSearchFunctionSearch
onNfSearchFormExportFunctionExport
nfColumCheckDialogVisibleBooleanColumn editing controls dialog/drawer display/hide
clearFilterFunctiontable clearFilter
sortFunctiontablesort
doLayoutFunctionTabledoLayout
clearSortFunctiontableclearSort
setCurrentRowFunctiontablesetCurrentRow
toggleRowExpansionFunctionTabletoggleRowExpansion
toggleAllSelectionFunctionTabletoggleAllSelection
toggleRowSelectionFunctiontabletoggleRowSelection
clearSelectionFunctiontableclearSelection
nfTableRefRefTable nf-table ref(div)
elTableRefReftable el-table ref
nfTableActionContainerRefRefTable actionBar ref(div)
nfTableActionBarRefRefTable actionBar ref(slot)
nfTablePaginationRefReftable pagination ref
nfSearchFormRefRefformnf-search-form ref
loadingInstanceInstanceloadingInstance
isLoadingbooleanTable loading status
columnCheckNfDrawerRefColumn editor nf-drawer ref
columnCheckDialogRefColumn editor column-check-dialog ref
columnCheckDrawerRefColumn editor column-check-drawer ref
showDataRecordPaginated data (handling front-end paging and back-end paging)

Instructions for use ​

searchApi({data, callback}) receives the converted form data and paging parameters. Callback should be called in finally whether it is successful or failed. Omit pageAttrs.total and use front-end paging. When total is passed in, the business party returns the current page data; asynchronous requests should prevent old responses from overwriting new queries.

The virtual table uses a fixed row height window and stable row-key, and no longer relies on the Vue 2 virtual table plug-in. Use normal mode for tree expansion, merged rows, and variable row height. Column settings and the old cookie naming method actually use IndexedDB. All examples are previewed within the document, and the floating layer will not be clipped by the iframe.