描述
插入选集(选框组)。
接口
void InsertCheckBoxGroup(const char* jsonCfg)
插入选集
/*********************************
* step1:给文档设置可使用的选项
* 方式一:调用接口SetOptions。打开文档后调用1次即可
* 方式二:右键菜单-知识库-选项 编辑可选项
* ********************************/
thinkEditor.SetOptions([
{
optionClass: "系统",
optionId: "性别",
items: [
{
id: "man",
groupId: "",
weight: 1.0,
content: "男性",
},
{
id: "woman",
groupId: "",
weight: 1.0,
content: "女性",
},
{
id: "unkown",
groupId: "",
weight: 1.0,
content: "未知性别",
},
],
}
]);
/*********************************
* step2:插入选集
* multipleChoice=0 单选
* multipleChoice=1 多选
* ********************************/
thinkEditor.InsertCheckBoxGroup({
checkFigureStyle: checkFigureStyle,
option: {
multipleChoice: multipleChoice,
optionClass: "系统",
optionId: "性别",
},
});
参数
{
"setMode": 1,
"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",
"optionClass": "系统",
"optionId": "性别",
"multipleChoice": 0,
"dynamicLoad": 0
},
"algorithm": {},
"expressions": []
}
参数名 | 必填 | 类型 | 说明 | 备注 |
---|---|---|---|---|
optionName | 是 | string | 选项名 | 用于标识不同的选项组实体 |
optionClass | 是 | string | 选项类 | |
optionId | 是 | float | 选项ID | |
json_cfg | 是 | json | 选框位域配置 | 桌面版为json_str web版为json_obj |
json_cfg参数
参数名 | 必填 | 类型 | 说明 | 备注 |
---|---|---|---|---|
checkFigureStyle | 是 | enum | 选框样式 | E_CHECK_FIGURE_STYLE |
multipleChoice | 否 | bool | 是否多选 | 0:单选 1:多选 |
enableEmpty | 否 | bool | 允许为空 | 0:默认,Content为空时,使用Item作为选框内容 1:Content为空时,选框内容为空 |
checked | 否 | json_arr | Json数组 | 没有该项时,默认都不选中。示例选中两项:{“checked”: [“选项1”,”选项2”]} |
返回值
类型 | 说明 | 备注 |
---|---|---|
bool | 插入是否成功 | 1:成功 0:失败 |
文档更新时间: 2025-04-21 23:31 作者:admin