@gridkitjs/core v0.12.0
Minor Changes#
-
183babc: The sorting, grouping, hiding and autofit built-in commands carry an
iconkey —sortAscending,sortDescending,group,hideandautoFit, typed as the newBuiltInCommandIcon— for a renderer to draw beside their labels. An app command may use the same keys. -
183babc: The controller has
clearColumnSort(columnId), which takes one column out of the sort and keeps the rest. ItsonColumnSortChangenames that column, where asetColumnSortleaving it out names the first key that changed — the next column, when it was the first key. The built-insort.clearcommand uses it, so clearing the first key of a multi-column sort reports the column cleared. -
22cf630: A column chooser model and the built-in
column.choosecommand, which asks the renderer to open the column chooser panel —host.openPanel("columnChooser", target)— on the grid, a toolbar or a header target.resolveColumnChooser({ columns, visibility, search })lists every data column for a search, hidden ones included, with whether each is shown and whether its checkbox is disabled (nothideable, or the last column shown), the tri-state of a "Show all" checkbox over the hideable columns the search lists, and which columns toggling it shows or hides — never one that is nothideable, and never the last column shown.GridMessageshas new keys:chooseColumns, the command's label;columnChooserLabel,columnChooserSearchLabel,showAllColumnsandnoMatchingColumnsfor the chooser; andcolumnsShown(count)andcolumnsHidden(count), announced when one change shows or hides more than one column. -
66c2815:
GridMessagesgainscolumnsAutoFitted(count)— "3 columns autofitted", "1 column autofitted" — announced when one action autofits more than one column. -
183babc: Three new grid options.
commandsregisters the app's own commands for its menus to list by id; one with a built-in's id replaces that built-in wherever it is listed.onCommandis called after a command or an inline menu item runs, with aGridCommandEvent—{ commandId, target, source },sourcebeing aGridCommandSource:"contextMenu","toolbar"or"api".onContextMenuOpenChangeis called as the grid's context menu opens or closes, with aContextMenuOpenChangeEvent—{ open, target }. -
183babc:
contextMenuhas three more areas besideheader:cell, a data cell's menu, acting on its row and cell;group, a group header row's; andbody, the body's empty space.defaultContextMenugivescellselect all rows, clear the selection, and expand or collapse every group;groupexpand or collapse every group and stop grouping by its column; andbodynothing, so empty space keeps the browser's menu until it is given entries.GridContextMenuTargetis a command target in one of the four areas.GridMessageshas three new keys naming these menus:cellMenuLabel("Row menu"),groupMenuLabel("Group menu") andbodyMenuLabel("Grid menu"). -
183babc: A
contextMenugrid option for the grid's own context menu on column headers, off by default.trueshows the defaults —defaultContextMenu: sort ascending and descending, clear the sort, group by and stop grouping, autofit the column or all of them, hide it, and choose the columns shown, each where the column allows;{ header: entries }lists a header's menu in the menu vocabulary, and{ header: [] }leaves the browser's menu.buildKeyShortcutstakes an optionalcontextMenucapability, which addsShift+F10.GridMessageshas three new keys:headerMenuLabel(columnName), a header menu's accessible name, andcolumnHidden(columnName)andcolumnShown(columnName), announced when one column is hidden or shown. -
183babc: A
contextMenuarea takes a function as well as entries, asked each time its menu opens with aGridContextMenuRequest—{ target, defaults, context }, the target typed for the area — and returning the entries to show, ornullfor the browser's menu there. It is how to add to an area's defaults, take some out, reorder them, or vary the menu by column or row:contextMenu: { cell: ({ target, defaults }) => target.columnId === "Id" ? null : ["orders.open", "separator", ...defaults], }For a renderer of its own,
contextMenuEntries(contextMenu, context)gives the entries for the placecontext.targetnames, asking an area's function if it has one, andhasContextMenu(contextMenu, area)says whether an area opens a grid menu at all.GridContextMenuEntriesis the type of an area's option. -
1fdf433:
columnValueOptionstakes an optionalmessagesin its query, the grid's own partialGridMessages. A boolean option is then labelledbooleanTrue/booleanFalse, the same words its cells use, andsearchmatches those labels. Without it, booleans still read"true"/"false".columnValueOptions(rows, dataColumns, filter, "Active", { locale, messages: { booleanTrue: "ja", booleanFalse: "nein" }, }); -
3758583: Grid commands: the one implementation behind a menu item, a toolbar button and a renderer's API.
builtInCommands()returns the grid's own — sort a column ascending or descending, clear its sort or all sorting, group and ungroup, expand or collapse every group, hide or autofit a column, select all rows, clear the selection, clear filters — each deciding from aGridCommandContextwhether it shows and whether it can run, and changing the grid only through the controller's actions.resolveCommands(commands)lays an app's own commands over them, replacing a built-in of the same id;createCommandContextbuilds the context for a header, cell, group, toolbar or grid target; andrunCommandruns a command only when it is visible and enabled.ColumnDefinitiontakeshideable(defaulttrue), which the built-incolumn.hidecommand honours;hideColumnsstill hides any column.GridMessageshas a new key for each built-in label —sortAscending,groupByColumn(columnName),clearFiltersand the rest. -
3758583: A menu model every renderer draws its menus from. A menu is a list of
MenuEntrys — command ids,"separator", inline items and submenus — andresolveMenu(entries, { commands, context })turns it into what to draw: hidden entries and unknown ids left out, labels resolved to strings,checkedset only on checkable items, separators never leading, trailing or doubled, empty submenus dropped, and each item'srun()bound to its context.nextMenuIndexandtypeaheadIndexare the pure halves of a menu's keyboard handling: where an arrow, Home or End key moves focus, skipping separators and wrapping, and which item a typed prefix picks. -
5f9a5da:
searchTextOf(filter)andsetSearchText(filter, text)read and write the filter's global text entry as a search box shows it:setSearchTextstores%text%— containstext, in any column — or removes the entry for empty text, leaving every column's entries alone;searchTextOfgives the text back without its%anchors, so a box reading from the filter shows what was typed. -
5f9a5da:
GridMessagesgains the toolbar's strings:toolbarLabel("Grid toolbar"),searchLabel("Search"),searchPlaceholder("Search…"),moreToolbarItems("More") andsearchResults(count)("3 rows found", "1 row found", "No rows found"), announced when a search settles. Amessagesobject that lists every key needs these five added. -
5f9a5da: A toolbar model, written in the menu vocabulary. A
ToolbarEntryis anyMenuEntry— a command id is a button, a checkable one a toggle, a submenu a dropdown — plus"search","spacer"and{ type: "custom", id }for a renderer's own content.resolveToolbar(entries, { commands, contextFor })resolves them byresolveMenu's rules, each item in a context targeting{ area: "toolbar", itemId }, and separators also collapse beside a spacer.GridToolbarOptions,defaultToolbar(search, spacer,filter.clearAll,column.choose) andtoolbarEntries(toolbar)describe thetoolbargrid option.For a toolbar too narrow for its items,
fitToolbarItemsworks out how many fit — pinned entries (search and custom, seeisPinnedToolbarItem) always stay, and room for a "More" button is kept only when something overflows — andsplitToolbarItemssplits the resolved items into what stays and the "More" menu's entries.A menu or toolbar entry naming no command is now reported as "the menu or toolbar entry
idnames no command, so it is left out." -
5f9a5da:
GridOptionsgainstoolbar?: boolean | GridToolbarOptions<Row>: a toolbar above the grid, off by default.truelistsdefaultToolbar— the search box, a spacer, "Clear filters" and "Choose columns" — and{ items, label }lists your own entries and names the toolbar for a screen reader.
Patch Changes#
- 1fdf433: A checklist filter on a date column whose cells hold ISO strings now opens with
its values checked after a restore.
restoreStaterevives a savedinlist toDates, which still filtered correctly, butinitialFilterEditorDraftshowed those values unchecked. Checklist values are now keyed the way theinoperator matches them, so on a date column a date string and theDateit names count as the same value.columnValueOptionsalso merges strings that spell the same date differently into one option, and returns the column'scolumnType, which the draft uses for keying. - db2ba38:
goToPage,nextPage,previousPageandsetPageSizeno longer fireonPaginationChangeor call subscribers when they leave the pagination as it was —nextPage()on the last page,previousPage()on the first,goToPage()to the page already shown. A controlled grid is no longer asked for the page it already has.