spatie / vue-table-component

A straight to the point Vue component to display tables
http://vue-table-component.spatie.be
MIT License
588 stars 149 forks source link

Suggestion: Ability to ignore new fetch request? (Only search for words longer than 2 characters) #144

Closed kaphert closed 6 years ago

kaphert commented 6 years ago

I am using this component with a remote dataset and pagination and it all works fine but I am trying to add the logic: only search if the filter is longer than 3 characters. Did somebody already figured this out?

The table component should keep its current state and do nothing when the filter value is between 1 and 3 characters long.

Or another usecase could be: start fetching data if the user stopped typing (after 500ms for example).

So actually what I am looking for is a validation method before the component starts fetching new data from the server. If the validation fails it should keep the current state.

I was thinking of something like the code below.

<table-component :data="fetchData" .... 
methods: {
  fetchData({page, filter, sort}) {
    if (!shouldFetch()) {
        return false;
    }

    // otherwise, fetch results from server and return them
  }
}

Above code is not working because the data property does not accept anything else than an array. What do you think? Should I create a pull request for this or is there another solution for my question?

spatie-bot commented 6 years ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.