Trace:
Differences
This shows you the differences between two versions of the page.
| — |
reactui:fetch_programmatically [2023/09/16 08:44] (current) admin created |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ~~NOTRANS~~ | ||
| + | ~~Title: Programmatically fetch~~ | ||
| + | If you use a work-screen for accessing your data, but the screen is completely customized (react code) you'll have a problem with record count. The number of initially loaded records is limited to 100 (set via startup request). If you open a custom screen, it only receives max. 100 records. This is not a problem if you use data components like table/grid or charts, because all standard components support lazy-loading of records. | ||
| + | If you have a custom screen, you have to do it on your own. The [[https://github.com/sibvisions/reactUI/tree/master/src/readme-files/requests|documentation]] contains detailed information. | ||
| + | |||
| + | Here's an example: | ||
| + | |||
| + | <file javascript> | ||
| + | import React, { FC, useEffect } from "react"; | ||
| + | import { REQUEST_KEYWORDS, ScreenWrapper, createFetchRequest, useAPI } from "@sibvisions/reactui"; | ||
| + | |||
| + | const ScreenWrapperContacts:FC<any> = (props) => { | ||
| + | const api = useAPI(); // use api to send a request to the server | ||
| + | |||
| + | // useEffect with empty dependency array to only call it once on mount! | ||
| + | useEffect(() => { | ||
| + | const fetchReq = createFetchRequest(); | ||
| + | fetchReq.dataProvider = "JVxMobileDemo/Con-CG/contacts#4"; // the name of your dataprovider | ||
| + | fetchReq.rowCount = -1; // -1 to receive all data | ||
| + | api.sendRequest(fetchReq, REQUEST_KEYWORDS.FETCH); | ||
| + | }, []); | ||
| + | |||
| + | return ( | ||
| + | <ScreenWrapper onOpen={onOpen}> | ||
| + | {workScreen => | ||
| + | <> | ||
| + | {workScreen} | ||
| + | </> | ||
| + | } | ||
| + | </ScreenWrapper> | ||
| + | ) | ||
| + | } | ||
| + | export default ScreenWrapperContacts | ||
| + | </file> | ||
| + | |||
| + | In above example, we use the the Contacts screen of our demo project. The dataprovider name is **JVxMobileDemo/Con-CG/contacts#4**. | ||
