FilterForm#
@palmyralabs/rt-forms-mui · grid/plugins/filter/FilterForm.tsx
Overview#
Filter-panel plugin. Renders an inline PalmyraForm whose fields are generated from the grid’s column definitions, wires Reset + Filter buttons to the grid’s queryRef, and calls onClose(filter) on apply.
Props — FilterOptions#
interface FilterOptions extends DataGridPluginOptions {
onClose?: (filter: any) => void;
column?: 1 | 2 | 3;
defaultFilter?: Record<string, any>;
}Behaviour#
- On mount: reads
queryRef.current.getCurrentFilter()and hydrates the form. - Reset clears the form and calls
queryRef.current.resetFilter(). - Filter calls
queryRef.current.setFilter(formData)and thenonClose(formData).
Example#
import { FilterForm } from '@palmyralabs/rt-forms-mui';
<PalmyraGrid
topic="manufacturer"
columns={manufacturerColumns}
endPoint="/mstManufacturer"
plugins={{ Filter: FilterForm }}
/>Internal helpers#
Two helpers in the same folder are used by FilterForm but aren’t barrel-exported:
FieldGenerator.tsx — getField#
function getField(fieldDef: FieldRequest): ReactElement;Maps a ColumnDefinition.type to the MUI form widget:
type |
Widget |
|---|---|
string (default) |
MuiTextField |
textarea |
MuiTextArea |
password |
MuiPassword |
number / float / integer |
MuiNumberField / MuiIntegerField |
select |
MuiSelect |
radio |
MuiRadioGroup |
checkbox |
MuiCheckBox |
switch |
MuiSwitch |
date |
MuiDatePicker |
datetime |
MuiDateTimePicker |
time |
MuiTimePicker |
dateRange |
MuiDateRangePicker |
rating |
MuiRating |
serverlookup |
MuiServerLookup |
GridFieldConverter.tsx — convertToField#
function convertToField(columns: ColumnDefinition[]): FieldRequest[];Strips non-filterable columns and reshapes the remaining ones into the FieldRequests that getField consumes.