vuetify: [Bug Report][3.3.1] VDataTable customFilter cannot access item.raw
Environment
Vuetify Version: 3.3.1 Last working version: 3.2.5 Vue Version: 3.3.4 Browsers: Google Chrome OS: Windows 10
Steps to reproduce
Use the reproduction link with Vuetify 3.3.1 and enter vanilla in the “Flavor search” input field. Notice there is nothing found. Then, set Vuetify to 3.2.5 and enter vanilla. Notice there are 2 items found. The flavor search uses a custom filter that searches a hidden “flavors” item property, which is accessed using item.raw within the filter function.
Expected Behavior
Custom filter should be able to access item.raw.
Actual Behavior
Custom filter throws an error in the console: “cannot read properties of undefined” (because item.raw is undefined).
Reproduction Link
Other comments
The line below was changed from 3.2.5 to 3.3.0. As of 3.3.0, only item.columns are accessible within custom filters in VDataTable. In v3.2.5 and earlier, item.raw was also accessible, allowing us to implement custom filters that access hidden item properties.
Can “item.raw” accessibility be restored in custom filters in VDataTable? Thank you for considering this issue.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 16 (6 by maintainers)
Commits related to this issue
- fix(filter): always pass raw item when using transform fixes #17487 — committed to vuetifyjs/vuetify by johnleider a year ago
- fix(filter): always pass InternalItem to custom filter function (#17832) fixes #17487 Co-authored-by: Kael <kaelwd@gmail.com> — committed to vuetifyjs/vuetify by johnleider 10 months ago
Sorting should have access to the full item too: #16654
Right now I’m toying with the idea to expose the transform function as a prop, something like
filterTransform. So for v-data-table the default value of it would beitem => item.columnsbut if you need to access raw object you can passitem => item.rawinstead.@nekosaur, good point about the apparent disconnect between input and output. One use case is a custom filter that searches expandable rows within a table. The custom filter would need access to the expanded-row data, which may include fields in
item.raw. Reference: https://vuetifyjs.com/en/components/data-tables/basics/#expandable-rowsI legit just pushed some changes for this like 5 minutes before you posted.
We’ve just hit this too. Seems like its broken all of our
customFiltersbecause we relied on the raw object being passed through.I have same issue. @KaelWD can you provide approximate time when team fix this? For my project this is core problem for now.
This was one thing I was afraid of when doing the change for 3.3.0. So yes I think we need to solve this somehow.
But at the same time, to me it feels quite strange to filter on data that is not visible in the table. There is a disconnect between the input and output…