描述
配置选框参数。不关心选框是否属于选集
接口
bool SetCheckBoxConfig(identity: object, config : object)参数
identity-参数
使用方式1:元素Id字符串
| 参数名 | 必填 | 类型 | 说明 | 备注 |
|---|---|---|---|---|
| id | 是 | string | 元素ID,为””时表示当前操作元素 |
thinkEditor.SetCheckBoxConfig("id1", config);使用方式2:identity通用身份对象
| 参数名 | 必填 | 类型 | 说明 | 备注 |
|---|---|---|---|---|
| 身份标识对象 | 是 | object | 目前支持 元素、表格 | 详见identity说明 |
thinkEditor.SetCheckBoxConfig({id:"id1"}, config);
or
thinkEditor.SetCheckBoxConfig({ids:["id1"]}, config);config-参数
| 参数名 | 必填 | 类型 | 说明 | 备注 |
|---|---|---|---|---|
| id | 否 | string | 选框id | |
| name | 否 | string | 选框name | |
| weight | 否 | float | 权值 | |
| content | 否 | string | 内容 | |
| checkFigureStyle | 否 | enum | 选框样式 | E_CHECK_FIGURE_STYLE |
| enableEmpty | 否 | bool | 是否-content可为空值 | |
| checked | 否 | bool or array | 选中状态 | identity按选集定位选框时checked=[‘itemId1’], 否则为单个选框使用checked=1 |
| sourceClass | 否 | string | 源种类 | |
| sourceId | 否 | string | 源Id |
config.option-选项
| 参数名 | 必填 | 类型 | 说明 | 备注 |
|---|---|---|---|---|
| Θ option | 否 | object | ||
| ┗ optionName | 否 | string | 运算集名 | 使用optionName标识不同的选集,不填时默认自动生成 |
| ┗ [过时] |
否 | string | 选项类 | 属于选集的选框该属性不为”” |
| ┗ [过时] |
否 | string | 选项组 | 属于选集的选框该属性不为”” |
| ┗ multipleChoice | 否 | bool | 是否-强制多选 | |
| ┗ required | 否 | bool | 是否-必选 | =1时,选集内多个选框至少有1个应当被选中 |
config参数示例
{
"object": "checkBox",
"checkFigureStyle": 1,
"enableEmpty": 0,
"id": "",
"name": "",
"text": "女性",
"content": "女性",
"fragment": "<Fragment><Format size='0.370'/><CheckBox xCfg='10' optionName='40lEe' itemId='女性' groupId='1' optionClass='系统' optionId='性别'><Format size='0.423'/><CF/><Format size='0.370'/>女性</CheckBox></Fragment>",
"checked": 0,
"onFocus": 0,
"itemId": "女性",
"groupId": "1",
"weight": "0.00",
"option": {
"optionName": "40lEe",
"multipleChoice": 0,
"dynamicLoad": 0
},
"algorithm": {},
"expressions": []
}案例:配置选中状态
方式1:按Id-设置单个选框选中状态
thinkEditor.SetCheckBoxConfig("id",
{
"checked": true
});方式2:按选集-设置多个选框选中状态
当选框属于选集时,可以使用如下方式配置多个选框状态
thinkEditor.SetCheckBoxConfig({/*identity*/
optionNames: ["groupName1"]
},
{/*config*/
"checked": [
"item1",
"item2"
]
});方式3:[过时-使用方式2代替]按选集-设置多个选框选中状态
- 注意:optionName 必填
thinkEditor.SetCheckBoxConfig("", {/*config*/ "option": { "optionName": "groupName1" }, "checked": [ "item1", "item2" ] });
algorithm-运算集
设置算法的前提是已经设置/加载了算法,本接口算法设置的目的是为对象选用需要参与的算法。
| 参数名 | 必填 | 类型 | 说明 | 备注 |
|---|---|---|---|---|
| algoGroup | 否 | string | 运算集名 | |
| algoRole | 否 | enum | 算法角色 | 0:输入 1:输出 E_ALGO_ROLE |
expressions-事件
添加事件
添加1个事件,需要如下三个参数都同时存在。一次可添加1个事件。
相同事件不会重复添加。
| 参数名 | 必填 | 类型 | 说明 | 备注 |
|---|---|---|---|---|
| event | 否 | int | 触发条件 | 0:值更改时 1:单击 2:双击 |
| mode | 否 | int | 执行模式 | 0:始终 1:一次 2:不执行 |
| action | 否 | string | 事件表达式 | 详情请咨询技术人员或查看《设计手册》 |
设置多个事件
- 如果已存在事件,则会清空替换
| 参数名 | 必填 | 类型 | 说明 | 备注 |
|---|---|---|---|---|
| expression | 否 | json arr | 表格式数组 |
{
"expression":
[
{
"event": "0",
"mode": "0",
"action": "this.element.value=='吸烟' ? smoke.element.visible=true:smoke.element.visible=false"
},
{
"event": "0",
"mode": "0",
"action": "this.element.value=='有食物或药物过敏史' ? allergen_desc.element.visible=true:allergen_desc.element.visible=false"
}
]
}返回值
| 类型 | 说明 | 备注 |
|---|---|---|
| bool | 是否有更新 | 0:设置失败 1:设置成功 |
文档更新时间: 2025-10-27 22:29 作者:admin