前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >jquery插件treetable 动态加载问题

jquery插件treetable 动态加载问题

作者头像
全栈程序员站长
发布2022-09-01 14:49:52
2.6K0
发布2022-09-01 14:49:52
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

使用jquery插件treetable 增加后刷新table时,树形样式丢失

在增加或修改后,动态加载html,开始就直接使用 $(“#treeTable tbody”).empty().append(data); 这个用法是错误的,

后来换成

代码语言:javascript
复制
//成功后刷新表格	
$("#treeTable tbody").empty();
var html = data.htmlTable; 
var node;  
$("#treeTable").treetable("loadBranch", node, html); 

就完成了,动态加载后保持树形table动作。

Public API

Plugin Function

treetable()

treetable() 方法可以传入下面的参数:

options(optional) : 一个描述配置的JS对象。

force(optional):参数为true时强制重新初始化树。

Additional Functions

对树操作的一些方法,附加方法必须通过treetable()方法调用。Eg:折叠id=42的节点, $(“#tree”).treetable(“collapseNode”, “42”).

collapseAll():折叠所有节点

collapseNode(id):Collapse a single node, identified by id.

expandAll():Expand all nodes at once.

expandNode(id):Expand a single node, identified by id.

loadBranch(node, rows):向树中插入新行(<tr>s), 传入参数 node 为父节点,rows为待插入的行. 如果父节点node为null ,新行被作为父节点插入

move(nodeId, destinationId):Move node nodeId to new parent with destinationId.

node(id):Select a node from the tree. Returns a TreeTable.Node object.

removeNode(id):从树中移除某个节点及其所有子节点

reveal(id):展示树中的某个节点

sortBranch(node)

sortBranch(node, columnOrFunction):根据字母顺序对node 节点的所有子节点排序。Defaults to sorting on the values in the configured tree column (see settings). Pass an optional column number or sorting function as the second argument columnOrFunction. See the tests for examples of custom sorting functions. Does not recursively sort children of children.

unloadBranch(node):Remove nodes/rows (HTML <tr>s) from the tree, with parent node. Note that the parent (node) will not be removed.

Classes

HTML tr class:

expanded:标识节点被展开

collapsed:标识节点被折叠

branch:分支节点,有子节点或者拥有 branchAttr 属性

leaf:叶子节点,无子节点

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/140808.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年5月2,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Public API
    • Plugin Function
      • Additional Functions
        • Classes
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档