In DataEase server we want to automate most of the heavy lifting when it comes to creating live forms that create, update, read and delete data from the server. If you follow a few rules when creating forms and naming field, the dataeaseconnect.js library will do the rest.

Goals of how it works

  1. All data is saved in the form fields.
  2. No data is cached.
  3. Load and save done using REST urls for the data object(s).
  4. The mapping to the real data is done in the fields.
  5. If field id match the field name in the table no extra action needed for mapping.
  6. If impossible to match field id or we deal with multiple data set, data-fieldname is used to match the field name in the table to the record.
  7. Table to update is implict the same as the url used for loading data.
  8. If impossible to match table name to url, a data-table is used to tell what table to save data.
  9. Reading and updating is done on one record using first parameter in url as the unique id.
  10. If impossible to use the first in url schema as unique id, you can set a data-query on the out most object for the field group.

Functions in deconn object

A normal template will load the dataeaseconnect.js library and assign it to a global var named deconn. This is the name we will use for the rest of the documentation.

Function Parameters Description
load Load a page into a content div. If you use a one page load all other data into this page, you can use this function to fetch the data from the server including the record data to show in a page form.
id the selector used for the page element to replace. Ex. "#appcontent" will replace the element with id="appcontent" with a new element loaded from the server.
urlpage type string or objectthe page to load into app content element
[urldata] optional the url for the table data to add to the page form
clearrecord Clear all data in a record. When saving data back to server this will we considered as a new record.
decodequery Returns an object consisting of all key value pair found after the ? in the url. Ex. /demo/createaddr/?ID=00001&InputName=Benny will give an object with two elements names ID and InputName with the values 00001 and Benny. This can be uses to construct f.ex. getrecord url based on paramters in this forms url.
getrecord Load data from the server based on the url given to the method
url url to data source like /maindata/TableName/?ID=uniqueid
[success] Called if data loaded successfully. This is to do other than the default form handling that are filling in all the data fetched from the server.
function signature to use are funtion(jdata,who,fromurl)
[failure] Called if data failed to load. Default is to put error message to an element with id="error"
function signature to use are funtion(jdata,who,fromurl)
getrecordcontent returns an object containing all field values from the form

More examples on how to use deconn later in the documentation.