Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug table.reset() #685

Closed
1 task done
xdecow opened this issue Mar 20, 2020 · 2 comments
Closed
1 task done

bug table.reset() #685

xdecow opened this issue Mar 20, 2020 · 2 comments
Assignees

Comments

@xdecow
Copy link

xdecow commented Mar 20, 2020

Issue Type (delete the irrelevant ones)

  • Bug

Specs

What version are you using?
2.19.1

What browser?
chrome 80

Expected Behavior

reset table filters and receive event filter-changed

Actual Behavior

the filters are reset but the event is not emitted
TypeError: Cannot read property 'forEach' of undefined

Steps to Reproduce the Problem

  1. create a table that has filters other than multiselect
  2. create a button that uses table.reset()

jsfiddle

https://jsfiddle.net/xdecow/5qLyhsfe/10/

note

In VgtFilterRow, the ref = "vgt-multiselect" is declared within an IF
you need to check if the instance exists before using foreach (line 108)

current:

function reset(emitEvent = false) {
      this.columnFilters = {};

      // Clear the selection in the multiselect
      this.$refs['vgt-multiselect'].forEach((ref) => {
        ref.clearSelection();
      });

      if (emitEvent) {
        this.$emit('filter-changed', this.columnFilters);
      }
    },

to:

function reset() {
      var emitEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      this.columnFilters = {}; // Clear the selection in the multiselect

      if ('vgt-multiselect' in this.$refs) {
        this.$refs['vgt-multiselect'].forEach(function (ref) {
          ref.clearSelection();
        });
      }

      if (emitEvent) {
        this.$emit('filter-changed', this.columnFilters);
      }
    },
@phena109
Copy link

phena109 commented May 1, 2020

I can confirm this is the case as I also run into the same issue. My application does not even activated any select functions.

Edit: Was making a PR and realised it's fixed in master already.

@xaksis
Copy link
Owner

xaksis commented May 9, 2020

I think this has been fixed. Will close once the new version is rolled out to npm.

@xaksis xaksis closed this as completed in 715b78a May 9, 2020
p0psicles pushed a commit to p0psicles/vue-good-table that referenced this issue Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants