Reusable lookup components
Accessing DataObject context
Applying field changes on selection
Example: Fleet transport work order location
import type { WorkOrdersRecord, WorkshopsRecord } from "@olenbetong/appframe-data";
import { useCurrentRow, useDataObject } from "@olenbetong/appframe-react";
import { BoundLookup } from "@olenbetong/appframe-mui";
export function WorkOrderLocationLookup() {
let workOrders = useDataObject<WorkOrdersRecord>();
let row = useCurrentRow(workOrders);
// row.WorkLocation contains the current value
return (
<BoundLookup<WorkOrdersRecord, WorkshopsRecord>
dataObject={dsWorkshops}
displayField="WorkLocation"
getChanges={(workshop) => ({
WorkLocation: workshop?.LocationID ?? null,
})}
/>
);
}Last updated
Was this helpful?