data binding
About 2 min
Control type
Control types mainly include the following types:
- Text control
- Date control
- Static drop-down box
- Dynamic drop-down box
- Radio button
- Checkbox
- Pictures
Control setting value
setBindObject(text, id)
single text setting
//Specify the control ID and set the display text
editor.setBindObject(text, id)
//Example
editor.setBindObject('Jacky Cheung', 'patientName')
setBindObject(obj)
Object settings
//Place the data object by ID name and set the corresponding text value of the medical record document object into the control
editor.setBindObject(obj)
//Example
let obj = {
patientNo: "2023010100009",
patientName: "Jiang Hualiang",
sex: "male",
age:"65 years old",
diagnosis: "COVID-19",
daigDate:"January 1, 2023",
clincName:"Respiratory Medicine",
bedNo:"16 beds"
}
editor.setBindObject(obj)
setBindObject(obj, id)
Put the data object by ID name and set the medical record document object value to the specified document node
//Example
let obj = {
patientNo: "2023010100009",
patientName: "Jiang Hualiang",
sex: "male",
age:"65 years old",
diagnosis: "COVID-19",
daigDate:"January 1, 2023",
clincName:"Respiratory Medicine",
bedNo:"16 beds"
}
editor.setBindObject(obj, 'base_info')
Note: The setBindObject and getBindObject functions can only be used after the document loading process is completed.
editor.loadUrl('./doc/100.html','100').then(function(){
let obj = {...}
editor.setBindObject(obj)
})
Control value
getBindObject(id)
Single control value
//Example
let patientName = editor.getBindObject('patientName')
getBindObject()
Get all value objects of the medical record document
let data = editor.getBindObject() //no parameters
console.log(data)
getBindObject(id)
Get all value objects of the specified document node
//Example
let data = editor.getBindObject('_head') //Specify the document node ID
console.log(data)
//return result
// {
// patientNo: "2023010100009",
// patientName: "Jiang Hualiang",
// sex: "male",
// age: "65 years old",
// diagnosis: "COVID-19",
// daigDate:"January 1, 2023",
// clincName:"Respiratory Medicine",
// bedNo: "16 beds"
// }
Control value (including encoding)
//Use the following method to obtain the encoding and value of a single control
let data = getBindObject(id, true)
//Use the following method to get the codes and values of all controls
let data = getBindObject(undefined, true)
Control setting value (including encoding)
//Use the following methods to set the encoding and value of a single control
editor.setBindObject(jsonObject, id, true)
//Use the following method to set the encoding and value of all controls
editor.setBindObject(jsonObject, undefined, true)
Bind table data
bindDataList()
- Insert table control
- Set the identifier
list
in the table attribute - Table attribute setting field
NUM name id
NUM is a reserved attribute name, and the row number will be automatically set - Use the editor.setDataList() method to bind the JSON object (object array) to the table control
//Editor initialization
editor.init(option)
//Load medical record document
editor.loadUrl('/doc/100.html','100').then(function(){
/** list data format example
[
{id '1111', name: 'aaa'},
{id '2222', name: 'bbb'},
{id '3333', name: 'ccc'}
]
**/
//Table binding data
if(editor.$('#list').length > 0){
$.get('/doc/list.json', (list)=>{
editor.bindDataList('list',list)
})
}
}
Get revision content
getRevision()
Returns a JSON array object of revision contents
editor.getRevision()
//return object
[
{
author:"revisor",
date:"revision time",
origin: "original text",
text: "Current text",
diff: "HTML content after text comparison"
}
]