question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple filter in table

See original GitHub issue

Hello, I’d like to request a feature of multiple filters. For example below there is a table with a search box and a predefined filter (select box).

2018-03-10 22 26 51

Filtering is processed by ajax, and It will be nice to have something like

<input v-model="filter.search" />
<select v-model="filter.roleId"> ... </select>
<b-table :filter="filter" :items="itemsProvider">...</b-table>

and then get

filter: {
    search: 'john',
    roleId: 1
}

inside ctx of itemsProvider, so I could get users with both name like ‘john’ and roleId equals 1 from my api.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:16
  • Comments:13

github_iconTop GitHub Comments

9reactions
alejotscommented, Jul 24, 2018

Hello!! I solved the problem with a computed method and Array.prototye.filter()

<b-table show-empty striped hover :items="invitationsFiltered">

</b-table>
computed: {
    invitationsFiltered: function () {
      var filtered = this.getInvitations.filter((el) => {
        return el.email.toLowerCase().indexOf(this.filterEmail.toLowerCase()) > -1 &&
              el.sent.toLowerCase().indexOf(this.filterSent.toLowerCase()) > -1 &&
              el.expires.toLowerCase().indexOf(this.filterExpires.toLowerCase()) > -1 &&
              el.update.toLowerCase().indexOf(this.filterUpdate.toLowerCase()) > -1 &&
              el.status.toLowerCase().indexOf(this.filterStatus.toLowerCase()) > -1
      })

      return filtered
    },
    ...mapGetters([
      'getInvitations'
    ])
  }
5reactions
adhatamacommented, Nov 5, 2018

For an alternative, I’ve got it worked by watch-ing the model filters then refresh the table. The refresh will trigger the itemsProvider

<input v-model="filters.search" />
<select v-model="filters.roleId"> ... </select>

<b-table ref="table" :items="itemsProvider">...</b-table>
data () {
    return {
         filters: {
             search: null,
             roleId: null
         }
    }
},

watch: {
    filters: {
        handler: function () {
              this.$refs.table.refresh()
        },
        deep: true
    }
},

methods: {
    itemsProvider: function (ctx, callback) {
         console.log(this.filters.search)
         console.log(this.filters.roleId)
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Apply Multiple Filters to Columns in Excel & Google Sheets
If you have a table with multiple columns in Excel, you can filter the data by multiple columns at once. Say you have...
Read more >
Can you have multiple filter tables on one sheet?
Hi I am trying to use several filter tables on one summary sheet but Excel seems to only allow one filter table at...
Read more >
Filter table with multiple filters - javascript - Stack Overflow
Filter table rows - Multiple filters · Create a function filterColumns( $someTableTarget ) that accepts as argument the jQuery wrapped ...
Read more >
DAX Table Function With Multiple Filters
DAX Table Function With Multiple Filters ... Hi experts,. I need help creating a table function that transforms a singular source table based...
Read more >
How to apply multiple filtering criteria by combining AND and ...
Applying multiple criteria against different columns to filter the data set in Microsoft Excel sounds difficult but it really isn't as hard ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found