CRUD / foldkit-mixins-crud
Add sorting, pagination, and custom cells
ts
PostTable(
{
page: Posts.page(model),
onOpen: row => Message.OpenedPost({ id: row.id }),
onMore: Message.RequestedMorePosts(),
sort: {
title: {
direction: model.postSort === 'title' ? 'asc' : undefined,
message: Message.SortedPosts({ sort: 'title' }),
},
},
cells: {
published: (row, h) => h.span([h.Class(row.published ? 'live' : 'draft')], ['●']),
},
words: { yes: 'Live', no: 'Draft', empty: 'No posts yet.', more: 'Load more', retry: 'Reload' },
},
h,
)When using a foldkit-crud Sort, pass PostSort.inputs(model.postSort, ...) for sort (see foldkit-crud). Customize every column of a Display kind using renderers (receiving the badge Slot for consistent styling), and customize localized strings via words (sharing no keys with form words; see words in one place).
Draw a detail view
ts
import { DetailView } from 'foldkit-mixins-crud'
const PostLines = DetailView.forMessages<Message>().define(PostDetail)
PostLines({ value: Shown.value(model) }, h)DetailView renders a <dl> with a <dt> and <dd> per shown field, supporting cells and words just like ListView.