API Reference

SmartCrudPage Props

TL;DR

A configuration-driven CRUD page component that automatically generates tables, search, forms, and details based on fieldsConfig.


๐Ÿ‘€ Minimal Example

import dynamic from 'next/dynamic'
const SmartCrudPage = dynamic(() => import('@/components/admin/smart-crud-page'), { ssr: false })

export default function Page() {
  return (
    <SmartCrudPage
      title="Example Management"
      fieldsConfig={[{ key: 'name', title: 'Name', type: 'text', search: { mode: 'like' }, form: { required: true } }]}
      actions={actions}
      enableCreate
    />
  )
}

๐Ÿ”ง Key Props

  • title: string โ€” Page title
  • fieldsConfig: FieldConfig[] โ€” Field configuration (drives table/form/search)
  • actions: { getList, getDetail?, create?, update, delete, batchUpdate?, batchDelete? }
  • rowKey?: string | (row) => string โ€” Default 'id'
  • enableCreate / enableEdit / enableDelete / enableDetail?: boolean
  • enableIndexColumn?: boolean โ€” Show global index column
  • tableApiRef?: React.Ref โ€” Exposes refresh / reloadAndRest / resetSearch / submitSearch / getSelectedRows
  • customToolbarButtons?: ReactNode[]
  • customRowActions?: { key, label, onClick, confirm?, showCondition? }[]
  • batchActions?: { key, label, action: (ids, params) => Promise }[]

๐Ÿ” Data Requests

  • Default uses actions.getList(params);
  • If dataSource + loading provided, enters controlled mode and no longer sends requests;
  • Detail drawer automatically uses getDetail (if exists).

๐Ÿ”Ž Search and Sort

  • Search form automatically generated from fieldsConfig.search;
  • Sorting triggered by clicking list headers, parameters passed to actions via buildSortCondition;
  • baseQuery can force additional fixed filters.

๐Ÿงช Callbacks and Extensions

  • beforeCreate(record) / beforeEdit(record) / beforeDelete(record) โ€” Return false to interrupt
  • renderDetailHeader(record) โ€” Custom detail header
  • onActionRefReady(actionRef, api) โ€” Callback when initially ready

  • Field Configuration: api/FIELDS_CONFIG
  • Form Component: api/SMART_FORM
  • CRUD Factory: api/CRUD_HELPER