How to use the xe-utils/methods/xe-utils.findTree function in xe-utils

To help you get started, we’ve selected a few xe-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xuliangzhan / vxe-table / packages / table / src / methods.js View on Github external
setTreeExpansion (rows, expanded) {
    let { fullAllDataRowMap, tableFullData, treeExpandeds, treeOpts, treeLazyLoadeds } = this
    let { lazy, hasChild, children, accordion } = treeOpts
    let result = []
    if (rows) {
      if (!XEUtils.isArray(rows)) {
        rows = [rows]
      }
      if (rows.length) {
        if (accordion) {
          rows = rows.slice(rows.length - 1, rows.length)
          // 同一级只能展开一个
          let matchObj = XEUtils.findTree(tableFullData, item => item === rows[0], treeOpts)
          XEUtils.remove(treeExpandeds, item => matchObj.items.indexOf(item) > -1)
        }
        if (expanded) {
          rows.forEach(row => {
            if (treeExpandeds.indexOf(row) === -1) {
              let rest = fullAllDataRowMap.get(row)
              let isLoad = lazy && row[hasChild] && !rest.treeLoaded && treeLazyLoadeds.indexOf(row) === -1
              // 是否使用懒加载
              if (isLoad) {
                result.push(this.handleAsyncTreeExpandChilds(row))
              } else {
                if (row[children] && row[children].length) {
                  treeExpandeds.push(row)
                }
              }
            }
github xuliangzhan / vxe-table / packages / table / src / methods.js View on Github external
isUpdateByRow (row, field) {
    let { visibleColumn, keepSource, treeConfig, treeOpts, tableSourceData, fullDataRowIdData } = this
    if (keepSource) {
      let oRow, property
      let rowid = UtilTools.getRowid(this, row)
      // 新增的数据不需要检测
      if (!fullDataRowIdData[rowid]) {
        return false
      }
      if (treeConfig) {
        let children = treeOpts.children
        let matchObj = XEUtils.findTree(tableSourceData, item => rowid === UtilTools.getRowid(this, item), treeOpts)
        row = Object.assign({}, row, { [ children ]: null })
        if (matchObj) {
          oRow = Object.assign({}, matchObj.item, { [ children ]: null })
        }
      } else {
        let oRowIndex = fullDataRowIdData[rowid].index
        oRow = tableSourceData[oRowIndex]
      }
      if (oRow) {
        if (arguments.length > 1) {
          return !XEUtils.isEqual(XEUtils.get(oRow, field), XEUtils.get(row, field))
        }
        for (let index = 0, len = visibleColumn.length; index < len; index++) {
          property = visibleColumn[index].property
          if (property && !XEUtils.isEqual(XEUtils.get(oRow, property), XEUtils.get(row, property))) {
            return true
github xuliangzhan / vxe-table / packages / table / src / methods.js View on Github external
          let matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), treeOpts)
          if (matchObj) {
github xuliangzhan / vxe-table / packages / table / src / methods.js View on Github external
scrollToTreeRow (row) {
    let { tableFullData, treeConfig, treeOpts } = this
    if (treeConfig) {
      let matchObj = XEUtils.findTree(tableFullData, item => item === row, treeOpts)
      if (matchObj) {
        let nodes = matchObj.nodes
        nodes.forEach((row, index) => {
          if (index < nodes.length - 1 && !this.isTreeExpandByRow(row)) {
            this.setTreeExpansion(row, true)
          }
        })
      }
    }
    return this.$nextTick()
  },
  /**
github xuliangzhan / vxe-table / packages / virtual-tree / src / virtual-tree.js View on Github external
rows.forEach(row => {
        let matchObj = XEUtils.findTree(fullTreeData, item => item === row, treeConfig)
        if (matchObj) {
          const { item, items, index, parent } = matchObj
          if (!this.isInsertByRow(row)) {
            removeList.push(row)
          }
          if (parent) {
            let isExpand = this.isTreeExpandByRow(parent)
            if (isExpand) {
              this.handleCollapsing(parent)
            }
            items.splice(index, 1)
            if (isExpand) {
              this.handleExpanding(parent)
            }
          } else {
            this.handleCollapsing(item)
github xuliangzhan / vxe-table / packages / table / src / methods.js View on Github external
appendTreeCache (row, childs) {
    let { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullDataRowMap, fullAllDataRowMap, fullAllDataRowIdData } = this
    let { children, hasChild } = treeOpts
    let rowkey = UtilTools.getRowkey(this)
    let rowid = UtilTools.getRowid(this, row)
    let matchObj
    if (keepSource) {
      matchObj = XEUtils.findTree(tableSourceData, item => rowid === UtilTools.getRowid(this, item), treeOpts)
    }
    XEUtils.eachTree(childs, (row, index) => {
      let rowid = UtilTools.getRowid(this, row)
      if (!rowid) {
        rowid = getRowUniqueId()
        XEUtils.set(row, rowkey, rowid)
      }
      if (row[hasChild] && XEUtils.isUndefined(row[children])) {
        row[children] = null
      }
      let rest = { row, rowid, index }
      fullDataRowIdData[rowid] = rest
      fullDataRowMap.set(row, rest)
      fullAllDataRowIdData[rowid] = rest
      fullAllDataRowMap.set(row, rest)
    }, treeOpts)
github xuliangzhan / vxe-table / packages / table / src / methods.js View on Github external
XEUtils.eachTree(this.collectColumn, column => {
        if (column.children && column.children.length) {
          column.visible = !!XEUtils.findTree(column.children, subColumn => subColumn.children && subColumn.children.length ? 0 : subColumn.visible, headerProps)
        }
      }, headerProps)
    }
github xuliangzhan / vxe-table / packages / virtual-tree / src / virtual-tree.js View on Github external
expandRowKeys.forEach(rowid => {
            let matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), treeConfig)
            let rowChildren = matchObj ? matchObj.item[children] : 0
            if (rowChildren && rowChildren.length) {
              this.setTreeExpansion(matchObj.item, true)
            }
          })
        }
github xuliangzhan / vxe-table / packages / table / src / methods.js View on Github external
getRowNode (tr) {
    if (tr) {
      let { treeConfig, treeOpts, tableFullData, fullAllDataRowIdData } = this
      let rowid = tr.getAttribute('data-rowid')
      if (treeConfig) {
        let matchObj = XEUtils.findTree(tableFullData, row => UtilTools.getRowid(this, row) === rowid, treeOpts)
        if (matchObj) {
          return matchObj
        }
      } else {
        if (fullAllDataRowIdData[rowid]) {
          let rest = fullAllDataRowIdData[rowid]
          return { item: rest.row, index: rest.index, items: tableFullData }
        }
      }
    }
    return null
  },
  /**
github xuliangzhan / vxe-table / packages / tools / src / utils.js View on Github external
destroyColumn (_vm) {
    let { $xetable, columnConfig } = _vm
    let matchObj = XEUtils.findTree($xetable.collectColumn, column => column === columnConfig)
    if (matchObj) {
      matchObj.items.splice(matchObj.index, 1)
    }
  },
  hasChildrenList (item) {