Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

展开树形表格时,会自动打开下级节点。 #1897

Closed
4 tasks done
airujingye opened this issue May 13, 2024 · 2 comments
Closed
4 tasks done

展开树形表格时,会自动打开下级节点。 #1897

airujingye opened this issue May 13, 2024 · 2 comments
Labels
need reproduce 需要提供最小化的重现示例 worksforme 无法重现

Comments

@airujingye
Copy link

airujingye commented May 13, 2024

议题条件

  • 我确认已查看官方使用文档:https://layui.dev ,但没有找到相关解决方案。
  • 我确认已在 Issues 中搜索过类似的问题,但没有找到相关解决方案。
  • 我已仔细阅读: 🍀 Layui Issue 贡献指南

议题类型

疑是 BUG

使用版本

v2.9.9

问题描述

加载树形表格后,第一次点开任意节点及下级节点时,都是正常展开的,点击哪个就展开哪个,当展开第二个或者第三个...第N个节点时,会自动展开下级节点,不是展开所有下级节点,是随机展开其中一个节点。树形表格数据是异步加载的。
一开始使用的是v2.9.0版本,升级到v2.9.9后问题同样存在。不确定是我使用问题还是bug问题,请指导,感谢!

业务代码

var inst = treeTable.render({
        elem: '#list',
        id: 'list',
        // url: HOST + '/tree/data',
        url: HOST + '/tree/data' + (category ? '?category=' + category : ''),
        tree: {
            // 异步加载子节点
            async: {
                enable: true,
                url: HOST + '/tree/data',
                autoParam: ["pid","id","type"]
            },
            customName: {
                isParent: 'isparent',
                pid: 'pid',
            },
            view: {
                showIcon: false
            },
        },
        height: 'full-35', // 最大高度减去其他容器已占有的高度差
        cols: [[
            {field: 'name', title: '标题', minWidth:500, templet: function(row) {
                    var title = row.name;
                    var tmpTitle = title.replace(/【加急】/g, "<span style='color: red;'>【加急】</span>");
                    tmpTitle = tmpTitle.replace(/【特急】/g, "<span style='color: red;'>【特急】</span>");
                    if (row.type === '3'){
                        return '<span style="color:#4D83AA;" lay-event="openProcess" href="javascript:void(0);">' + tmpTitle + '</span>'
                    }else {
                        return '<span style="color:#4D83AA;" href="javascript:void(0);">' + tmpTitle + '</span>'
                    }
                }},
            {field: 'todo_time', title: '转发时间', align: 'center', width: 200},
            {title: '操作', width: 200, align: 'center', toolbar: '#barDemo'},
        ]],

    });

//监听单击展开事件
    treeTable.on('row(list)', function (obj) {
        console.log(obj.data) //得到当前行数据
        console.log('index: obj.data.LAY_DATA_INDEX', obj.data.LAY_DATA_INDEX) //得到当前行数据
        if (obj.data.LAY_EXPAND){
            //收缩
            treeTable.expandNode('list',{
                inherit: false,
                index: obj.data.LAY_DATA_INDEX,
                expandFlag: !obj.data.LAY_EXPAND // 展开or收缩
            })
        }else {
            treeTable.expandNode('list',{
                inherit: false,
                //展开
                index: obj.data.LAY_DATA_INDEX,
                expandFlag: !obj.data.LAY_EXPAND // 展开or收缩
            })
        }
    });

截图补充

WechatIMG1738

浏览器

版本 124.0.6367.202(正式版本) (x86_64)

演示地址

No response

友好承诺

  • 我承诺将本着相互尊重、理解和友善的态度进行交流,共同维护 Layui 良好的社区氛围。
@Sight-wcg Sight-wcg added the need reproduce 需要提供最小化的重现示例 label May 13, 2024
Copy link

@airujingye 你好,请提供一个最小化的重现,以便我们为你协助排查问题。良好的重现应当包括但不仅限于:

  • 产生问题的详细步骤
  • 与问题相关的完整代码
  • 在线 Demo (推荐通过 stackblitzcodepen 创建)

详见:🍀 Layui Issue 贡献指南
延伸:👉 为什么要提供最小化重现?

@Sight-wcg Sight-wcg added the worksforme 无法重现 label May 13, 2024
Copy link

由于超过 3 天仍未收到相关重现或其他更多信息,该 issue 已被自动关闭。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need reproduce 需要提供最小化的重现示例 worksforme 无法重现
Projects
None yet
Development

No branches or pull requests

2 participants