DataObjectContext
When components/hooks bind to data objects, they use the data object from the DataObjectContext. This is a simple React context that returns only the data object you pass to the provider.
The provider can also bind some keyboard shortcuts to functions of the data object by setting the enableKeyboard property to true:
Ctrl + S - Calls endEdit on the data object
Escape - If the data object is dirty, cancel the changes. If not, the event will keep bubbling.
Example
In this example, the BoundTextField component is bound to the Title field of dsMyDataObject. The CurrentTitle component demonstrates how you get the data object from the context, and then uses the current row to render the Title field.
import {
DataObjectProvider,
useCurrentRow,
useDataObject,
} from "@olenbetong/appframe-react";
import { BoundTextField } from "@olenbetong/appframe-mui";
function CurrentTitle() {
let dataObject = useDataObject();
let row = useCurrentRow(dataObject);
return row.Title;
}
function MyComponent() {
return (
<DataObjectProvider enableKeyboard dataObject={dsMyDataObject}>
<BoundTextField field="Title" />
<CurrentTitle />
</DataObjectProvider>
);
}API
Last updated
Was this helpful?