File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -221,8 +221,30 @@ const { t } = useLocale()
221221const appConfig = useAppConfig () as Table [' AppConfig' ]
222222
223223const data = ref (props .data ?? []) as Ref <T []>
224- const columns = computed <TableColumn <T >[]>(() => props .columns ?? Object .keys (data .value [0 ] ?? {}).map ((accessorKey : string ) => ({ accessorKey , header: upperFirst (accessorKey ) })))
225224const meta = computed (() => props .meta ?? {})
225+ const columns = computed <TableColumn <T >[]>(() => processColumns (props .columns ?? Object .keys (data .value [0 ] ?? {}).map ((accessorKey : string ) => ({ accessorKey , header: upperFirst (accessorKey ) }))))
226+
227+ function processColumns(columns : TableColumn <T >[]): TableColumn <T >[] {
228+ return columns .map ((column ) => {
229+ const col = { ... column } as TableColumn <T >
230+
231+ if (' columns' in col && col .columns ) {
232+ col .columns = processColumns (col .columns as TableColumn <T >[])
233+ }
234+
235+ if (! col .cell ) {
236+ col .cell = ({ getValue }) => {
237+ const value = getValue ()
238+ if (value === ' ' || value === null || value === undefined ) {
239+ return ' \u00A0 '
240+ }
241+ return String (value )
242+ }
243+ }
244+
245+ return col
246+ })
247+ }
226248
227249const ui = computed (() => tv ({ extend: tv (theme ), ... (appConfig .ui ?.table || {}) })({
228250 sticky: props .sticky ,
You can’t perform that action at this time.
0 commit comments