The data will be Eclair Dark and Eclair Light with new values, to test the multi filtering in the right way.Īnd the v-data-table header templates for Calories and Fat. Ok, for now, he have a column that allow you to filter the data in it, but this is not a multi filtering, so we gonna do the same for the columns Calories and Fat, and add more data to the dessert array. In the computed property filteredDesserts we create the array conditions, and check every time that the variable dessertName is filled, if so, we add the method filterDessertName to the conditions, and then, we return the desserts array filtering every condition that have in the conditions array:Īnd the column name filtered will be like: To this we add it to the property v-model of the v-text-field in the menu of the column template, and add a click event on the v-btn to clean the input data.Ī method is needed to filter the data when dessertName is filled, so we call it filterDessertName, and pass a argument called item to access the property name of the desserts array.īut, to the method work and return the data filtered, we need to create a computed property and call it in the prop items of the v-data-table. Now we gonna need a variable, that we will called it dessertName to filter the data. The first thing to do is use a slot for the header of the column name, that we will add a icon to activate a menu, that will have a v-text-field to filter the data and a button to clean the input. So, i will take the common v-data-table used in the Vuetify documentation: So i search for other solution and i find many other ways, but the only one that allowed multi filter column independent of the filtering order, was the one that i will show here. I know that there is a solution for this if you see the documentation for custom filter in data table, but i tried and for some reason it didn’t work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |