Trace: • Data API
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
flutterui:data_api [2020/08/06 22:55] admin created |
flutterui:data_api [2020/08/06 23:18] (current) admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ## Managing data in a screen | + | ~~Title: Data API~~ |
+ | ~~NOTRANS~~ | ||
+ | ~~NOPDF~~ | ||
- | For managing the data of a screen, the **CustomScreen** provides a simple API which can be accessed via **getDataApi('DATA_PROVIDER_NAME')** from anywhere in it's extended classes. | + | For managing the data of a screen, the **CustomScreen** provides a simple API which can be accessed via ''%%getDataApi('DATA_PROVIDER_NAME')%%'' from anywhere in it's extended classes. |
- | This API provides the following functions: | + | This API provides following functions: |
- | - dynamic **getValue**(String columnName) - Provides the value of a specific column | + | * ''%%dynamic getValue(String columnName)%%''\\ Provides the value of a specific column |
- | - List **getValues**(List columnNames) - Provides a list of values for the specified columns | + | * ''%%List getValues(List columnNames)%%''\\ Provides a list of values for the specified columns\\ |
- | - **setValue**(String columnName, dynamic value) - Sets the value for a specific column | + | * ''%%setValue(String columnName, dynamic value)%%''\\ Sets the value for a specific column |
- | - **setValues**(List columnNames, List values) - Sets the values for a list of specified columns | + | * ''%%setValues(List columnNames, List values)%%''\\ Sets the values for a list of specified columns |
- | - **insertRecord**() - Inserts a new record | + | * ''%%insertRecord()%%''\\ Inserts a new record |
- | - **deleteRecord**(int index) - Deletes the record at the specified index | + | * ''%%deleteRecord(int index)%%''\\ Deletes the record at the specified index |
- | - **selectRecord**(int index) - Selects the record at the specified index | + | * ''%%selectRecord(int index)%%''\\ Selects the record at the specified index |
The client persists those changes by itself. | The client persists those changes by itself. | ||
- | ## Examples | + | === Examples === |
- | Reading a value: | + | |
- | DataApi dataApi = getDataApi('JVxMobileDemo/Con-CG/contacts#4'); | + | ==Reading a value== |
+ | |||
+ | <file dart> | ||
+ | DataApi dataApi = getDataApi('JVxMobileDemo/Con-CG/contacts#4'); | ||
| | ||
- | FlatButton( | + | FlatButton( |
- | child: Text("Call"), onPressed: () { | + | child: Text("Call"), onPressed: () { |
- | phone = dataApi.getValue("PHONE"); | + | phone = dataApi.getValue("PHONE"); |
- | launch("tel://$phone"); | + | launch("tel://$phone"); |
}) | }) | ||
+ | </file> | ||
- | Setting a value: | + | ==Setting a value== |
- | DataApi dataApi = getDataApi('JVxMobileDemo/Con-CG/contacts#4'); | + | <file dart> |
- | dynamic phoneNr = '+43660123456' | + | DataApi dataApi = getDataApi('JVxMobileDemo/Con-CG/contacts#4'); |
| | ||
- | FlatButton( | + | FlatButton( |
- | child: Text("Set phone number"), onPressed: () { | + | child: Text("Set phone number"), onPressed: () { |
- | phone = dataApi.setValue("PHONE", phoneNr); | + | phone = dataApi.setValue("PHONE", '+43660123456'); |
- | }) | + | } |
+ | ) | ||
+ | </file> | ||
- | Inserting a record: | + | == Inserting a record == |
- | DataApi dataApi = getDataApi('JVxMobileDemo/Con-CG/contacts#4'); | + | <file dart> |
+ | DataApi dataApi = getDataApi('JVxMobileDemo/Con-CG/contacts#4'); | ||
| | ||
- | FlatButton( | + | FlatButton( |
- | child: Text("Insert"), onPressed: () { | + | child: Text("Insert"), onPressed: () { |
- | phone = dataApi.insertRecord(); | + | phone = dataApi.insertRecord(); |
- | }) | + | } |
+ | ) | ||
+ | </file> | ||
- | More examples can be found [here](https://github.com/sibvisions/flutterclient.example/blob/master/lib/screens/signature_custom_screen.dart) and [here](https://github.com/sibvisions/flutterclient.example/blob/master/lib/screens/contact_custom_screen.dart). | + | More examples can be found [[https://github.com/sibvisions/flutterclient.example/blob/master/lib/screens/signature_custom_screen.dart|here]] and [[https://github.com/sibvisions/flutterclient.example/blob/master/lib/screens/contact_custom_screen.dart|here]]. |