javascript - 是否可以在jstree中为父级设置单选按钮和为子级设置复选框按钮?
问题描述
我希望父节点像单选按钮一样,但它的所有子节点都是复选框按钮,单独使用“multiple:true”是不够的,我想要的是通过单击/检查一个父节点,所有其他父节点应该是未选中,请参见以下代码,希望有人能帮助我找出解决方案,谢谢。
.on('changed.jstree', async (e, data) => {
const node = data.instance.get_node(data.node, true); // current clicked and checked parent checkbox
let siblings = node.siblings('li[aria-level="1"]'); // all other parent checkboxs
for (let i = 0; i < siblings.length; i++) {
let sibling = siblings[i];
sibling.ariaSelected = false; // all other parent checkboxs should be unchecked, that's my objective!
$.jstree.reference('#').refresh(sibling); // try to reflect change in UI but not working
}
$.jstree.reference('#').redraw(true); // try to reflect changes in UI but not working
});
解决方案
推荐阅读
- php - Fullcalendar 显示可用用户而不是占用用户(反转逻辑)
- java - 将流映射到原始索引列表
- amazon-web-services - 如何获取 AWS CodeDeploy 日志并在 BitBucket 管道中显示它们
- git - 不要在 git grep 输出中显示 ^M(回车)
- angularjs - 如果文本长度为零,则显示 ui-select-no-choice 消息
- python-3.x - Dask 比香草蟒最低?我做错了什么?
- excel - 宏运行很快,直到运行不同的宏
- r - 如何根据R中的位置向量替换字符串向量中的字符?
- python - 内置 round() 函数使用 numpy 改变其行为
- sql - SQL select in a month 但是当一天超过三组时,只显示前三组的所有数据