Happy-Coding-Clans / vue-easytable

A powerful data table based on vuejs. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.
https://happy-coding-clans.github.io/vue-easytable/
MIT License
3.69k stars 738 forks source link

[Feature Request] How to do refresh on the table grid #528

Closed Fikri32 closed 1 year ago

Fikri32 commented 1 year ago

I am opening an issue for

vue-easytable

Issue Type

Feature

Issue Title

How to do refresh on the table grid

What problem does this feature solve?

How to do refresh on the table grid?i want to table can refresh every one minutes

What does the proposed API look like?

read documentation

huangshuwei commented 1 year ago

It is data driven. You just need to synchronize the data every minute

Fikri32 commented 1 year ago

can you give me a reference please?

huangshuwei commented 1 year ago

Use setInterval in the mounted lifecycle,Here is an example. Online demo

<template>
    <ve-table
        :columns="columns"
        :table-data="tableData"
        :border-around="true"
        :border-x="true"
        :border-y="true"
    />
</template>

<script>
    export default {
        data() {
            return {
                columns: [
                    { field: "name", key: "a", title: "Name" },
                    { field: "date", key: "b", title: "Date" },
                    { field: "hobby", key: "c", title: "Hobby" },
                    { field: "address", key: "d", title: "Address" },
                ],
                tableData: [],
            };
        },
        methods: {
            initTableData() {
                const date = new Date().getTime();

                this.tableData = [
                    {
                        name: date,
                        date: date,
                        hobby: date,
                        address: "-",
                    },
                    {
                        name: "Dickerson",
                        date: date,
                        hobby: "-",
                        address: "-",
                    },
                ];
            },
        },
        mounted() {
            this.initTableData();
            setInterval(() => {
                this.initTableData();
            }, 500);
        },
    };
</script>