0

I am trying build a table that is filtered by checkboxes. I have 3 objects:

  • selected: What check boxes are currently selected
  • sites: What populates the checkboxes. Object Structure: sites: [{ siteid, name } ...]
  • items: all table items. Object Structure: items: [{siteid, gradeid, cpl} ..]

Pastebin: https://pastebin.com/J2kBr2Xy CodePen: https://codepen.io/tomdickson/pen/OqXpay

Hope this provides enough information

2
  • 2
    No, it does not. Please show us your code and tell us your problem. Otherwise it is hard to guess what you want to know. Commented Mar 1, 2019 at 10:58
  • @SebastianvomMeer Thanks for the feedback mate, I have updated my question and added both a Pastebin and Codepen Commented Mar 4, 2019 at 0:14

1 Answer 1

1

Try this code. I think this will work.

computed: {
    filteredPositions () {
      return this.items.filter(item => this.selected.includes(item.siteid));
    }
  }

Fiddle - https://jsfiddle.net/8x3yer54/1/

Just replace computed with this and it works fine.

computed: {
        filteredSite() {
            if (!this.selected.length || this.selected.includes(true)) 
                return this.items

             return this.items.filter(item => this.selected.find((item2) => item2.site==item.site))
        }
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Patel, unfortunately this hasn't worked but I think it is something I am missing. I have updated my question with a link to the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.