How to use the xe-utils.isArray 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-demo / vxe-table-by-vue-grid-proxy / src / plugins / table.js View on Github external
function sendAjax (options, callback, defaultCallback) {
  if (options && !XEUtils.isArray(options)) {
    const ajaxOpts = Object.assign({ method: 'GET' }, XEUtils.isString(options) ? { url: options } : options)
    XEAjax(ajaxOpts).then(response => response.json()).then(callback)
    if (defaultCallback) {
      defaultCallback()
    } else {
      callback()
    }
  }
}
github xuliangzhan / vxe-table / packages / table / src / table.js View on Github external
insertAt (records, row) {
      let { tableData, editStore, defineProperty } = this
      if (!XEUtils.isArray(records)) {
        records = [records]
      }
      let newRecords = records.map(record => defineProperty(record))
      if (arguments.length === 1) {
        tableData.unshift.apply(tableData, newRecords)
      } else {
        if (row === -1) {
          tableData.push.apply(tableData, newRecords)
        } else {
          let rowIndex = tableData.indexOf(row)
          tableData.splice.apply(tableData, [rowIndex, 0].concat(newRecords))
        }
      }
      [].unshift.apply(editStore.insertList, newRecords)
      this.checkSelectionStatus()
      return this.$nextTick().then(() => {
github xuliangzhan / vue-element-extends / packages / editable / src / editable.vue View on Github external
revert (records, prop) {
      this.currentRow = null
      if (records) {
        if (!XEUtils.isArray(records)) {
          records = [records]
        }
        XEUtils.eachTree(this.datas, row => {
          if (records.includes(row.data)) {
            if (prop) {
              XEUtils.set(row.data, prop, XEUtils.get(row.store, prop))
            } else {
              XEUtils.destructuring(row.data, XEUtils.clone(row.store, true))
            }
          }
        }, this.elTreeOpts)
      } else {
        this._clearAllOpers()
        return this.reload(this.initialStore)
      }
      return this.$nextTick()
github xuliangzhan / vue-element-extends / packages / editable / src / editable.vue View on Github external
reset (records = this._getData()) {
      let columns = this.getColumns()
      if (records && !XEUtils.isArray(records)) {
        records = [records]
      }
      records.forEach(record => {
        columns.forEach(column => {
          if (column.property) {
            XEUtils.set(record, column.property, null)
          }
        })
      })
      return this.$nextTick()
    },
    getColumns () {
github xuliangzhan / vxe-table / packages / table / src / table.js View on Github external
beginValidate (rows, cb, isAll) {
      let validRest = {}
      let status = true
      let { editRules, tableData } = this
      let vaildDatas = tableData
      if (rows) {
        if (XEUtils.isFunction(rows)) {
          cb = rows
        } else {
          vaildDatas = XEUtils.isArray(rows) ? rows : [rows]
        }
      }
      let validPromise = Promise.resolve(true)
      this.lastCallTime = Date.now()
      this.clearValidate()
      if (!XEUtils.isEmpty(editRules)) {
        let columns = this.getColumns()
        vaildDatas.forEach(row => {
          let rowIndex = tableData.indexOf(row)
          columns.forEach((column, columnIndex) => {
            if (XEUtils.has(editRules, column.property)) {
              validPromise = validPromise.then(() => new Promise((resolve, reject) => {
                this.validCellRules('all', row, column)
                  .then(resolve)
                  .catch(({ rule, rules }) => {
                    let rest = { rule, rules, rowIndex, row, columnIndex, column }
github xuliangzhan / vue-element-extends / packages / editable / src / editable-column.vue View on Github external
bindProps () {
      let sortBy
      let clsName = this.isReadonly ? 'elx_readonly ' : 'elx_edit '
      if (this.className) {
        clsName += `${this.className} `
      }
      if (this.renderOpts.autofocus) {
        clsName += 'elx_autofocus '
      }
      if (XEUtils.isFunction(this.sortBy)) {
        sortBy = this.sortBy
      } else if (XEUtils.isString(this.sortBy)) {
        sortBy = `data.${this.sortBy}`
      } else if (XEUtils.isArray(this.sortBy)) {
        sortBy = this.sortBy.map(name => `data.${name}`)
      } else if (this.sortable && this.prop) {
        sortBy = `data.${this.prop}`
      }
      return {
        type: this.scrollLoad ? null : this.type,
        label: this.label,
        columnKey: this.columnKey,
        prop: this.prop,
        width: this.width,
        minWidth: this.minWidth,
        fixed: this.fixed,
        sortable: this.sortable,
        sortMethod: this.sortMethod ? this.sortMethodEvent : this.sortMethod,
        sortBy,
        sortOrders: this.sortOrders,
github xuliangzhan / vue-element-extends / packages / editable / src / editable.vue View on Github external
_spanMethod ({ row, column, rowIndex, columnIndex }) {
      let rowspan = 1
      let colspan = 1
      if (this.spanMethod) {
        var result = this.spanMethod({ row: row.data, column, rowIndex, columnIndex })
        if (XEUtils.isArray(result)) {
          rowspan = result[0]
          colspan = result[1]
        } else if (XEUtils.isPlainObject(result)) {
          rowspan = result.rowspan
          colspan = result.colspan
        }
      }
      return { rowspan, colspan }
    },
    _load (row, treeNode, resolve) {
github xuliangzhan / vxe-table / packages / table / src / table.js View on Github external
setSelection (rows, value) {
      if (rows && !XEUtils.isArray(rows)) {
        rows = [rows]
      }
      rows.forEach(row => this.triggerCheckRowEvent({}, { row }, !!value))
      return this.$nextTick()
    },
    /**