How to add individual filters for data-table in vuetify?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 15:57:18

问题


I've a data table <v-data-table> that has tons of records and have 7 columns. Vuetify's data table has one filter for all of them and it is working, but I want individual filter for all of the columns.

I'm getting the data from the backend using axios, then filter the data, push it into an array and then display it in the table.

How do I go about that?

I'm new at Vue, and I am not working with Vuex for this project. I've looked at other questions on stack-overflow but they are mostly talking about custom filters.

<v-data-table :headers="headers" :items="this.results" :search="search" :date="this.date">
     <template v-slot:items="props" v-slot:date="props">
        <tr>
          <td>{{ props.item.time }}</td>
          <td>{{ props.item.station }}</td>
          <td>{{ props.item.number }}</td>
          <td>{{ props.item.name }}</td>
          <td><v-icon color="red">clear</v-icon></td>
          <td> <v-btn small flat color="info" @click="openModal(props.item)">Show Results</v-btn></td>
        </tr>
      </template>

<!--  These are the filters for individual columns. Shown only two for brevity. -->

      <template v-slot:footer>
         <td>
           <v-text-field
             v-model="search"
             prepend-inner-icon="schedule"
             label="Time"
             size="10"
             single-line
            ></v-text-field>
          </td>
          <td>
            <v-text-field
              v-model="search"
              prepend-inner-icon="ev_station"
              label="Staion"
              single-line
              size="10"
            ></v-text-field>
           </td>
           <td></td>
           <td></td>
           <td></td>
           <td></td>
       </template>
</v-data-table>
data() {
    return {
      date: [],
      search: '',
    };
  },

来源:https://stackoverflow.com/questions/56065402/how-to-add-individual-filters-for-data-table-in-vuetify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!