Giter Club home page Giter Club logo

easytable's Introduction

npm vue3.2 NPM downloads license

@easytable/vue

Warning

本仓库迁移自 vue-easytable Vue.js 2.x ,基于 Vue.js 3.x 重构中,目前基本完成。

English | 中文

介绍

一个强大的 vue3.x 表格组件。你可以将它用做数据表、微软 excel 或者 goole sheet. 支持虚拟滚动、单元格编辑等功能。

Important

如果您正在使用 Vue2.x ,请使用 vue-easytable 组件库。

特点

  • 采用虚拟滚动技术,支持 30 万行数据展示
  • 永久免费。当然你也可以选择捐赠

API & 文档

功能支持

基础组件

Table 组件

如果没有你想要的的功能 ,请告诉我们

安装

pnpm install @easytable/vue

or

yarn add @easytable/vue

使用

Write the following in main.js:

import { createApp } from 'vue';
import '@easytable/vue/libs/theme-default/index.css';
import { useVeTable } from '@easytable/vue';

createApp({
  render: (h) => h(App),
})
.use(useVeTable())
.mount('#app');

Example:

<template>
  <ve-table :columns="columns" :table-data="tableData" />
</template>

<script>
  export default {
    data() {
      return {
        columns: [
          { field: "name", key: "a", title: "Name", align: "center" },
          { field: "date", key: "b", title: "Date", align: "left" },
          { field: "hobby", key: "c", title: "Hobby", align: "right" },
          { field: "address", key: "d", title: "Address" },
        ],
        tableData: [
          {
            name: "John",
            date: "1900-05-20",
            hobby: "coding and coding repeat",
            address: "No.1 Century Avenue, Shanghai",
          },
          {
            name: "Dickerson",
            date: "1910-06-20",
            hobby: "coding and coding repeat",
            address: "No.1 Century Avenue, Beijing",
          },
          {
            name: "Larsen",
            date: "2000-07-20",
            hobby: "coding and coding repeat",
            address: "No.1 Century Avenue, Chongqing",
          },
          {
            name: "Geneva",
            date: "2010-08-20",
            hobby: "coding and coding repeat",
            address: "No.1 Century Avenue, Xiamen",
          },
          {
            name: "Jami",
            date: "2020-09-20",
            hobby: "coding and coding repeat",
            address: "No.1 Century Avenue, Shenzhen",
          },
        ],
      };
    },
  };
</script>

开发计划

正在做的事情

支持环境

  • 现代浏览器和 IE11 及以上
IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions

如何贡献

如果你希望参与贡献,欢迎 Pull Request

Star History

Star History Chart

贡献者们

感谢原组件库作者 huangshuwei

同时感谢以下小伙伴们做出的贡献 🙏

License

http://www.opensource.org/licenses/mit-license.php

easytable's People

Contributors

kohaiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

endday

easytable's Issues

超长文本提示还是存在问题

item.renderBodyCell = () => h('div', '测试内容');

输出后超长 title 提示还是显示为 [object Object]

我查了下 vNode 取文本貌似没有很好的解决方案。源码 body-td.txs 文件 350-356 部分:


      // ellipisis
      if (column.ellipsis) {
        const { showTitle } = column.ellipsis

        // default true
        const isShowTitle = isBoolean(showTitle) ? showTitle : true

        content = (
          <span
            title={isShowTitle ? getTextContentOfVNode(content) : ''}
            style={this.getEllipsisContentStyle()}
            class={clsName('body-td-span-ellipsis')}
          >
            {content}
          </span>
        )
      }

getTextContentOfVNode 这个函数取文本也不是很完美,是不是直接使用 rawCellValue 代替更好?顺便将 span 换成 div,如:

          <div
            title={isShowTitle ? rawCellValue  : ''}
            style={this.getEllipsisContentStyle()}
            class={clsName('body-td-span-ellipsis')}
          >
            {content}
          </div>

不过不论哪种方案都不能很好解决,因为 rawCellValue 本身也不一定是文本,也可能是对象。

要么就手动增加一个输出 title 函数

列在文件超长时,显示的提示异常

当 column 的 ellipsis 属性开启时,如果此列是自定义渲染的,则 title 值将出现错误,如:

image

column.ellipsis = { lineClamp: 2, showTitle: true }
column.renderBodyCell = (option) => h('div', option.row[option.column.key]);

此时 title 显示的不是提示文本,而是对象。建议 title 提示的时候直接取 td 中 innerText 即可。

点击表格header或左侧操作列后,再点击body区域,前端报错:Cannot read properties of null (reading 'includes')

你好。我遇到了一个问题,不知道你这边是否有这个问题。
image
点击图片中的红色区域后,再点击绿色区域时,前端报错,报错信息如下:
image
示例代码如下:

<template>
    <div class="app-container">
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button
                        type="primary"
                        plain
                        icon="Plus"
                        size="large"
                        @click="handleAdd"
                >新增
                </el-button>
            </el-col>
        </el-row>
        <ve-table
                rowKeyFieldName="rowKey"
                :columns="columns"
                :table-data="tableData"
                borderY
                :cell-autofill-option="cellAutofillOption"
                :sort-option="sortOption"
                :columnHiddenOption="columnHiddenOption"
                :rowStyleOption="rowStyleOption"
                :column-width-resize-option="columnWidthResizeOption"
        />
        <!--
        :editOption="editOption"
        -->
    </div>
</template>
<script setup lang="tsx">
    import {ref} from 'vue'
    import '@easytable/vue/libs/theme-default/index.css';
    import {VeTable} from '@easytable/vue';
    import * as dayjs from "dayjs";
    const sortOption = ref({
        // sort always
        sortAlways: true,
        sortChange: (params) => {
            sortChange(params);
        },
    })
    const editOption = ref({
        beforeStartCellEditing: ({row, column, cellValue}) => {
            console.log("beforeStartCellEditing");
            console.log("row::", row);
            console.log("column::", column);
            console.log("cellValue::", cellValue);
            console.log("---");
            if (row.R === '已审核') {
                return false;
            }
        },
        beforeCellValueChange: ({row, column, changeValue}) => {
            console.log("beforeCellValueChange");
            console.log("row::", row);
            console.log("column::", column);
            console.log("changeValue::", changeValue);

            console.log("---");

            if (column.field === "number" && !/^\d+$/.test(changeValue)) {
                alert("请输入数字");
                return false;
            }
        },
        afterCellValueChange: ({row, column, changeValue}) => {
            console.log("afterCellValueChange");
            console.log("row::", row);
            console.log("column::", column);
            console.log("changeValue::", changeValue);
            console.log("---");
        },
    })
    const columnResizeInfo = ref({
        column: "",
        differWidth: "",
        columnWidth: "",
        tableWidth: "",
    })
    const columnWidthResizeOption = ref({
        // default false
        enable: true,
        // column resize min width
        minWidth: 30,
        // column size change
        sizeChange: ({column, differWidth, columnWidth}) => {
            columnResizeInfo.value.column = column;
            columnResizeInfo.value.differWidth = differWidth;
            columnResizeInfo.value.columnWidth = columnWidth;
        },
    })
    const rowStyleOption = ref({
        clickHighlight: true,
        hoverHighlight: true,
        stripe: true
    })
    const cellAutofillOption = ref(true)
    const columnHiddenOption = ref({
        // default hidden column keys
        defaultHiddenColumnKeys: ["id"],
    })
    const columns = [
        {
            field: "index",
            key: "index",
            operationColumn: true,
            title: "",
            width: 50,
            align: "center",
            renderBodyCell: ({row, column, rowIndex}, h) => {
                return ++rowIndex;
            },
            edit: false,
        },
        {key: "id", edit: false, title: "id", field: "id"},
        {key: "A", edit: false, title: "A", field: "A", fixed: "left" },
        {key: "B", edit: true, title: "B", field: "B", fixed: "left", sortBy: ""},
        {key: "C", edit: true, title: "C", field: "C", fixed: "left", sortBy: ""},
        {key: "D", edit: true, title: "D", field: "D", sortBy: ""},
        {key: "E", edit: true, title: "E", field: "E", sortBy: ""},
        {key: "F", edit: true, title: "F", field: "F", sortBy: ""},
        {key: "G", edit: true, title: "G", field: "G", sortBy: ""},
        {key: "H", edit: true, title: "H", field: "H", sortBy: ""},
        {key: "I", edit: true, title: "I", field: "I", sortBy: ""},
        {key: "J", edit: true, title: "J", field: "J", sortBy: ""},
        {key: "K", edit: true, title: "K", field: "K", sortBy: ""},
        {key: "L", edit: true, title: "L", field: "L", sortBy: ""},
        {key: "M", edit: true, title: "M", field: "M", sortBy: ""},
        {key: "N", edit: true, title: "N", field: "N", sortBy: ""},
        {key: "O", edit: true, title: "O", field: "O", sortBy: ""},
        {key: "P", edit: true, title: "P", field: "P", sortBy: ""},
        {key: "Q", edit: true, title: "Q", field: "Q", sortBy: ""},
        {key: "R", edit: false, title: "R", field: "R", sortBy: ""},
        {
            field: "",
            key: "e",
            title: "S",
            width: "",
            center: "left",
            fixed: "right",
            renderBodyCell: ({ row, column, rowIndex }, h) => {
                return(
                    <span>
                        <el-button
                            class="button-demo"
                            onClick={() => deleteRow(rowIndex)}
                        >
                                        删除
                                    </el-button>
                                </span>
                );
            },
        }]
    const tableData = ref([])
    const cjtimeOptions = ref(['4:00', '8:00', '10:00', '12:30', '14:00', '16:30', '17:30'])
    const maxRowKey = ref(0);
    initTableData()
    function initTableData() {
        let data = [];
        let length = 10, min = 0, max = 100;
        for (let i = 0; i < length; i++) {
            data.push({
                rowKey: i,
                id: Math.floor(Math.random() * length) + 1,
                A: `a`,
                B: dayjs(new Date()).format("YYYY-MM-DD"),
                C: getRandomCjtime(),
                D: (Math.random() * (max - min) + min).toFixed(2),
                E: (Math.random() * (max - min) + min).toFixed(2),
                F: (Math.random() * (max - min) + min).toFixed(2),
                G: (Math.random() * (max - min) + min).toFixed(2),
                H: (Math.random() * (max - min) + min).toFixed(2),
                I: (Math.random() * (max - min) + min).toFixed(2),
                J: (Math.random() * (max - min) + min).toFixed(2),
                K: (Math.random() * (max - min) + min).toFixed(2),
                L: (Math.random() * (max - min) + min).toFixed(2),
                M: (Math.random() * (max - min) + min).toFixed(2),
                N: (Math.random() * (max - min) + min).toFixed(2),
                O: (Math.random() * (max - min) + min).toFixed(2),
                P: (Math.random() * (max - min) + min).toFixed(2),
                Q: (Math.random() * (max - min) + min).toFixed(2),
                R: Math.random() >= 0.5 ? '已审核' : '未审核'
            });
            maxRowKey.value = i;
        }
        tableData.value = data;
    }

    function getRandomCjtime() {
        const randomIndex = Math.floor(Math.random() * cjtimeOptions.value.length);
        return cjtimeOptions.value[randomIndex]
    }

    function handleAdd() {
        addNewItem()
    }

    function addNewItem() {
        const newObject = columns.reduce((obj, {field}) => {
            if (field === "A") {
                obj[field] = "a"
            } else if (field === "B") {
                obj[field] = dayjs(new Date()).format("YYYY-MM-DD");
            } else if (field === "C") {
                const randomIndex = Math.floor(Math.random() * cjtimeOptions.value.length);
                obj[field] = cjtimeOptions.value[randomIndex]
            } else if (field === "id") {
                obj[field] = parseInt(Math.floor(Math.random() * 10000) + 1)
            } else if (field === "R") {
                obj[field] = '未审核';
            } else {
                if (field !== 'index') {
                    obj[field] = parseFloat((Math.random() * (0 - 0) + 0).toFixed(2)); // 假设值在0到100之间
                }
            }
            obj.rowKey = maxRowKey.value + 1;
            return obj;
        }, {});
        tableData.value.unshift(newObject);
        maxRowKey.value = maxRowKey.value + 1;
        console.log("tableData-->", tableData)
    }

    function deleteRow(rowIndex) {
        tableData.value.splice(rowIndex, 1);
    }

    function sortChange(params) {
        let prop = "";
        const json = JSON.parse(JSON.stringify(params))
        // 遍历键值对
        Object.entries(json).forEach(([key, value]) => {
            if (value != "") {
                prop = key;
            }
        });
        tableData.value.sort((a, b) => {
            if (params[prop] === "asc") {
                return a[prop] - b[prop];
            } else if (params[prop] === "desc") {
                return b[prop] - a[prop];
            } else {
                return 0;
            }
        });
    }
</script>

nuxt error

错误 [nuxt] [请求错误] [未处理] [500] HTMLElement 未定义
  在./node_modules/@easytable/vue/libs/es/packages/ve-contextmenu/src/index.js:34:22
  在 process.processTicksAndRejections (节点:内部/进程/task_queues:95:5)
  在异步 ViteNodeRunner.runModule (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.mjs:362:5)
  在异步 ViteNodeRunner.directRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.mjs:346:5)
  在异步 ViteNodeRunner.cachedRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.mjs:189:14)
  在异步 ViteNodeRunner.dependencyRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.mjs:233:12)
  在异步./node_modules/@easytable/vue/libs/es/packages/ve-contextmenu/index.js:2:31
  在异步 ViteNodeRunner.runModule (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.mjs:362:5)
  在异步 ViteNodeRunner.directRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.mjs:346:5)
  在异步 ViteNodeRunner.cachedRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.mjs:189:14)

Cuòwù [nuxt] [qǐngqiú cuòwù] [wèi chǔlǐ] [500] HTMLElement wèi dìngyì
  zài./Node_modules/@easytable/vue/libs/es/packages/ve-contextmenu/src/index.Js:34:22
  Zài process.ProcessTicksAndRejections (jiédiǎn: Nèibù/jìnchéng/task_queues:95:5)
  Zài yìbù ViteNodeRunner.RunModule (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.Mjs:362:5)
  Zài yìbù ViteNodeRunner.DirectRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.Mjs:346:5)
  Zài yìbù ViteNodeRunner.CachedRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.Mjs:189:14)
  Zài yìbù ViteNodeRunner.DependencyRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.Mjs:233:12)
  Zài yìbù./Node_modules/@easytable/vue/libs/es/packages/ve-contextmenu/index.Js:2:31
  Zài yìbù ViteNodeRunner.RunModule (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.Mjs:362:5)
  Zài yìbù ViteNodeRunner.DirectRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.Mjs:346:5)
  Zài yìbù ViteNodeRunner.CachedRequest (/media/drei/Local%20Repo/Vue/Startup/bookeeph/node_modules/vite-node/dist/client.Mjs:189:14)

npm 包少了文件

image

import VeLocale from './packages/ve-locale';

ve-locale 没有打包进去,TS 找不到类型

Excel demo按照Vue3组合式函数写法写完后,展示正常,但滑动事件触发时表格非常卡,且表格渲染的行数不正常,白屏

在组件中引入以下hooks可复现

组件代码:


<script setup> import { onMounted } from "vue"; import { useEasyTable } from "@/hooks/useEasyTable"; import { VeLocale } from "@easytable/vue"; import zhCN from "@easytable/vue/libs/locale/lang/zh-CN.js"; VeLocale.use(zhCN); const [initTableData, columns, tableData, virtualScrollOption, cellAutofillOption, editOption, contextmenuBodyOption, contextmenuHeaderOption, rowStyleOption, columnWidthResizeOption] = useEasyTable(); onMounted(() => { initTableData() }) </script> <style lang="scss" scoped> </style>

hooks代码:
import { ref } from 'vue'
import { h } from 'vue'

export function useEasyTable() {

// 列名
const COLUMN_KEYS = [
	"A",
	"B",
	"C",
	"D",
	"E",
	"F",
	"G",
	"H",
	"I",
	"J",
	"K",
	"L",
	"M",
	"N",
	"O",
	"P",
	"Q",
	"R",
	"S",
	"T",
	"U",
	"V",
	"W",
	"X",
	"Y",
	"Z",
];
// const COLUMN_KEYS = [
// 	{
// 		"prop_name": "state",
// 		"type": "viewOrderState",
// 		"do_not_delete": true,
// 		"#readonly_controlled": "\u53d7\u6743\u9650\u63a7\u5236\u7684\u72b6\u6001\uff0c\u8fd9\u79cd\u5b57\u6bb5\u4f1a\u6839\u636e\u64cd\u4f5c\u7528\u6237\u62e5\u6709\u7684\u6743\u9650\u8bbe\u7f6e\u662f\u5426\u53ea\u8bfb\uff0cpropName\u76ee\u524d\u9700\u8981\u662fcolumns\u4e2d\u5b58\u5728\u7684\u5c5e\u6027\uff0cby\uff0cpermission.js\u5b9a\u4e49\u7684\u6743\u9650",
// 		"readonly_controlled": {
// 			"propName": "state",
// 			"type": "order",
// 			"infectToRowWhenReadonly": false
// 		},
// 		"read_only": true,
// 		"refresh": "row",
// 		"label": "\u72b6\u6001",
// 		"width": "80px",
// 		"placeholder": "\u8bf7\u9009\u62e9\u7533\u8bf7\u5355\u72b6\u6001",
// 		"extra": {
// 			"url": "/api/restful/query/base/variable_option/options?object=li_ord_order&code=state&option=label__label,value__value"
// 		}
// 	},
// 	{
// 		"prop_name": "state",
// 		"type": "viewOrderOperate",
// 		"do_not_delete": true,
// 		"label": "\u64cd\u4f5c",
// 		"readonly_controlled": {
// 			"propName": "state",
// 			"type": "order",
// 			"infectToRowWhenReadonly": false
// 		},
// 		"width": "160px",
// 		"placeholder": "\u8bf7\u64cd\u4f5c",
// 		"refresh": "row",
// 		"read_only": true
// 	},
// 	{
// 		"prop_name": "number",
// 		"type": "elinput",
// 		"do_not_delete": true,
// 		"label": "\u7f16\u53f7",
// 		"width": "160px",
// 		"placeholder": "\u8bf7\u8f93\u5165\u7533\u8bf7\u5355\u7f16\u53f7"
// 	},
// 	{
// 		"prop_name": "customer.name",
// 		"type": "elinput",
// 		"label": "\u5ba2\u6237",
// 		"width": "240px",
// 		"placeholder": "\u8bf7\u8f93\u5165\u5ba2\u6237"
// 	},
// 	{
// 		"prop_name": "ownerId",
// 		"show_prop_name": "owner.name",
// 		"do_not_delete": true,
// 		"type": "elrSelect",
// 		"label": "\u5ba2\u6237\u7ecf\u7406",
// 		"width": "100px",
// 		"placeholder": "\u8bf7\u9009\u62e9\u5ba2\u6237\u7ecf\u7406",
// 		"extra": {
// 			"url": "/api/restful/query/system/user/all?in_filter=model.system.user.User.id__user_ids&user_ids.module=model.system.user_position.UserPosition.user_id&user_ids.in_filter=model.system.user_position.UserPosition.position_id__positions&user_ids.positions.module=model.system.position.Position.id&user_ids.positions.equal_filter=model.system.position.Position.code__sale&equalFilter=model.system.user.User.state_valid__valid&option=label__name,value__id&order_by=model.system.user.User.id&per_page=300"
// 		}
// 	},
// 	{
// 		"prop_name": "customer.contactName",
// 		"type": "elinput",
// 		"label": "\u8054\u7cfb\u4eba",
// 		"width": "104px",
// 		"placeholder": "\u8bf7\u8f93\u5165\u8054\u7cfb\u4eba"
// 	},
// 	{
// 		"prop_name": "customer.contactPhone",
// 		"do_not_delete": true,
// 		"type": "elinput",
// 		"label": "\u8054\u7cfb\u7535\u8bdd",
// 		"width": "130px",
// 		"placeholder": "\u8bf7\u8f93\u5165\u8054\u7cfb\u7535\u8bdd"
// 	},
// 	{
// 		"prop_name": "customer.contactAddress",
// 		"type": "elinput",
// 		"label": "\u8054\u7cfb\u5730\u5740",
// 		"width": "180px",
// 		"placeholder": "\u8bf7\u8f93\u5165\u8054\u7cfb\u5730\u5740"
// 	},
// 	{
// 		"prop_name": "inputTime",
// 		"type": "eldate",
// 		"label": "\u5f55\u5165\u65f6\u95f4",
// 		"width": "110px",
// 		"placeholder": "\u8bf7\u9009\u62e9\u5f55\u5165\u65f6\u95f4"
// 	},
// 	{
// 		"prop_name": "remark",
// 		"web_type": "elinput",
// 		"type": "elinput",
// 		"label": "\u5907\u6ce8\u4fe1\u606f",
// 		"width": "160px",
// 		"placeholder": "\u8bf7\u8f93\u5165\u5907\u6ce8\u4fe1\u606f",
// 		"props": {
// 			"options": [
// 				{
// 					"value": "",
// 					"label": ""
// 				}
// 			]
// 		}
// 	},
// 	{
// 		"prop_name": "priority",
// 		"web_type": "elinput",
// 		"type": "elinput",
// 		"label": "\u4f18\u5148\u7ea7",
// 		"width": "160px",
// 		"placeholder": "\u8bf7\u8f93\u5165\u4f18\u5148\u7ea7",
// 		"props": {
// 			"options": [
// 				{
// 					"value": "",
// 					"label": ""
// 				}
// 			]
// 		}
// 	},
// 	{
// 		"prop_name": "shareReport",
// 		"do_not_delete": true,
// 		"type": "viewReporthShare",
// 		"label": "\u62a5\u544a\u5206\u4eab",
// 		"width": "180px",
// 		"placeholder": "\u62a5\u544a\u5206\u4eab",
// 		"read_only": true
// 	}
// ];
const columns = ref([
	{
		field: "index",
		key: "index",
		// is operation column
		operationColumn: true,
		title: "",
		width: 55,
		fixed: "left",
		renderBodyCell: renderRowIndex,
	},
])
columns.value = columns.value.concat(
	COLUMN_KEYS.map((keyValue) => {
		return {
			title: keyValue,
			field: keyValue,
			key: keyValue,
			width: 90,
			edit: true,
		};
	})
);

const tableData = ref([])
// 初始化表格数据
function initTableData() {
	for (let i = 0; i < 5000; i++) {
		let dataItem = {
			rowKey: i,
		};

		COLUMN_KEYS.forEach((keyValue) => {
			dataItem[keyValue] = "";
		});

		if (i === 1 || i === 3) {
			dataItem["C"] = "YOU";
			dataItem["D"] = "CAN";
			dataItem["E"] = "TRY";
			dataItem["F"] = "ENTER";
			dataItem["G"] = "SOME";
			dataItem["H"] = "WORDS";
			dataItem["I"] = "!!!";
		}

		tableData.value.push(dataItem);
	}
	
	tableData.value = tableData.value;
}

// start row index
let startRowIndex = 0

// render row index
function renderRowIndex({ row, column, rowIndex }) {
	// return <span>{rowIndex + startRowIndex.value + 1}</span>;	// 需将本文件名后缀改为jsx
	
	// h函数 https://cn.vuejs.org/api/render-function.html#h
	return h('span', { class: '', innerHTML: rowIndex + startRowIndex + 1 })
}


function scrolling({startRowIndex, visibleStartIndex, visibleEndIndex, visibleAboveCount, visibleBelowCount}) {
	startRowIndex = startRowIndex;
}

const virtualScrollOption = {
	// 是否开启
	enable: true,
	scrolling: scrolling,
}

const columnWidthResizeOption = {
	enable: true,
}

const cellAutofillOption = {
	directionX: true,
	directionY: true,
	beforeAutofill: ({
		direction,
		sourceSelectionRangeIndexes,
		targetSelectionRangeIndexes,
		sourceSelectionData,
		targetSelectionData,
	}) => { },
	afterAutofill: ({
		direction,
		sourceSelectionRangeIndexes,
		targetSelectionRangeIndexes,
		sourceSelectionData,
		targetSelectionData,
	}) => { },
}

// edit option 可控单元格编辑
const editOption = {
	beforeCellValueChange: ({ row, column, changeValue }) => { },
	afterCellValueChange: ({ row, column, changeValue }) => { },
}

// contextmenu header option
const contextmenuHeaderOption = {
	/*
		 before contextmenu show.
		 In this function,You can change the `contextmenu` options
		 */
	beforeShow: ({
		isWholeColSelection,
		selectionRangeKeys,
		selectionRangeIndexes,
	}) => {
		//
	},
	// after menu click
	afterMenuClick: ({
		type,
		selectionRangeKeys,
		selectionRangeIndexes,
	}) => {
		//
	},

	// contextmenus
	contextmenus: [
		{
			type: "CUT",
		},
		{
			type: "COPY",
		},
		{
			type: "SEPARATOR",
		},
		{
			type: "EMPTY_COLUMN",
		},
		{
			type: "SEPARATOR",
		},
		{
			type: "LEFT_FIXED_COLUMN_TO",
		},
		{
			type: "CANCEL_LEFT_FIXED_COLUMN_TO",
		},
		{
			type: "RIGHT_FIXED_COLUMN_TO",
		},
		{
			type: "CANCEL_RIGHT_FIXED_COLUMN_TO",
		},
	],
}

// contextmenu body option
const contextmenuBodyOption = {
	/*
		 before contextmenu show.
		 In this function,You can change the `contextmenu` options
		 */
	beforeShow: ({
		isWholeRowSelection,
		selectionRangeKeys,
		selectionRangeIndexes,
	}) => {
		console.log("---contextmenu body beforeShow--");
		console.log("isWholeRowSelection::", isWholeRowSelection);
		console.log("selectionRangeKeys::", selectionRangeKeys);
		console.log("selectionRangeIndexes::", selectionRangeIndexes);
	},
	// after menu click
	afterMenuClick: ({
		type,
		selectionRangeKeys,
		selectionRangeIndexes,
	}) => {
		console.log("---contextmenu body afterMenuClick--");
		console.log("type::", type);
		console.log("selectionRangeKeys::", selectionRangeKeys);
		console.log("selectionRangeIndexes::", selectionRangeIndexes);
	},

	// contextmenus
	contextmenus: [
		{
			type: "CUT",
		},
		{
			type: "COPY",
		},
		{
			type: "SEPARATOR",
		},
		{
			type: "INSERT_ROW_ABOVE",
		},
		{
			type: "INSERT_ROW_BELOW",
		},
		{
			type: "SEPARATOR",
		},
		{
			type: "REMOVE_ROW",
		},
		{
			type: "EMPTY_ROW",
		},
		{
			type: "EMPTY_CELL",
		},
	],
}

const rowStyleOption = {
	clickHighlight: false,
	hoverHighlight: false,
}

return [initTableData, columns, tableData, virtualScrollOption, cellAutofillOption, editOption, contextmenuBodyOption, contextmenuHeaderOption, rowStyleOption, columnWidthResizeOption]

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.