Coder Social home page Coder Social logo

Comments (2)

dwqs avatar dwqs commented on June 16, 2024

do you have a reproduce demo

from v2-table.

sknightq avatar sknightq commented on June 16, 2024

@dwqs I had got my aim with my custom code. Because the component instance of columns'slots can't be got in updateColumnsWidth function, which results in the wrong width of the table when columns' slot updated. Your code only call the updateColumnsWidth in mounted hook.
So I recall the handleWinResize in updated hook with this.$nextTick method. Of course, I add some computed attributes in child component "table-body.js"

some code snippets:

// table.vue
// to update the columns width
        updated () {
            this.$nextTick(function () {
                this.handleWinResize();
                if (this.rowsChange) {
                    this.updateScrollbar(true);
                    this.rowsChange = false;
                }        
            });
        }
// table.vue
// detect neccessary resize
            handleWinResize () {
                const newColumns = this.$slots.default.filter(function (column) {
                    return column.componentInstance && column.componentInstance.$options.name === 'v2-table-column';
                }).map(function (column) {
                    return column.componentInstance;
                });

                if (this.$el.clientWidth === this.containerWidth && this.columns.length === newColumns.length) {
                    return;
                } else {
                    this.bodyMinWidth = undefined;
                }

                this.containerWidth = this.$el.clientWidth;
                this.containerHeight = this.$el.clientHeight;
                
                // this.columns = [].concat(this.updateColumnsWidth(this.columns));
                this.columns = [].concat(this.updateColumnsWidth());

                if (this.rightColumns.length) {
                    this.rightColumns = [].concat(this.getColumnComponentsByType(this.columns, 'right'));
                }
                if (this.leftColumns.length) {
                    this.leftColumns = [].concat(this.getColumnComponentsByType(this.columns, 'left'));
                }

                if (this.scrollbar) {
                    this.updateScrollbar(true);
                }
            }

from v2-table.

Related Issues (20)

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.