-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Way to retrieve (watch) the filtered Items from the searchTableItems function of a VDataTable? #8731
Comments
Thanks a lot for th suggestion to use $refs.transactionsTable._data.internalCurrentItems !
The problem with this is pagination when the amount of filtered Items is
bigger than the Rows per Page number (which is the case for me).
this.$refs.tableRefName._data.internalCurrentItems only gives me back the
filtered Items of the current table page which I'm looking at. I would need to retrieve the entire filtered table Items from the search.
Any further suggestions are much appreciated.
Cheers Tim
Am Do., 12. Sept. 2019 um 09:36 Uhr schrieb FF128 <[email protected]
…:
Try to get the filtered items w/ this code:
this.$refs.tableRefName._data.internalCurrentItems
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#8731?email_source=notifications&email_token=ALZF4QCVEWLW52XHIUVVOMDQJHWORA5CNFSM4IPOXZKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6Q6RDI#issuecomment-530704525>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALZF4QBLOK64R2PPXUNTHPDQJHWORANCNFSM4IPOXZKA>
.
|
Shouldn't it be the default behaviour? |
This comment has been minimized.
This comment has been minimized.
I filter the data with 3 filters (by date and by text search) and then export the result to csv. In pseudocode:
Right now it seems the only way, until this is fixed. |
Hi |
Any news on this? |
This would be super helpful. |
Until it there is an official solution, I was able to find the search results nested in the refs.
|
This would be super helpful! Thanks to @PushyPants for current workaround. My use case is I want to filter the items in the datatable and then be able to retrieve them to export the list to a csv file. |
Thank you, @PushyPants for the workaround! |
Thank you, @PushyPants! improved solution with sorted records
|
you can also directly get sorted and filtered items:
|
Elements on the current page, taking into account pagination: Total number of filtered items: |
Maybe I'm being daft here, but I'm struggling with accessing any of items you mentioned above. True, I'm using a v-data-iterator rather than v-data-table, but I have added the ref and @update like this
and have the pleaserWork method as per...
The log out of this.$refs shows the propPanelIter, which I can expand and see filteredItems and the $children array, but anythig I try to access on propPanelIter always returns can't read property of undefined. |
@tompinnacle (most likely) the reason you're having an issue is that you're looking for the ref at the same time the DOM is being updated. That's why when you try to access it, it's undefined. It doesn't exist until it's fully written to the DOM. I had this problem a bunch when I first started developing VUE... luckily vue has a built in method for dealing with this called NextTick. Here is a link to the docs but I'll give you a short rundown on it here. Basically it waits until the DOM has completely updated to run the callback function you provide. So like in your case... you want to run pleaseWork() after the pagination has finished updating the DOM, you'd do something like this:
That should fix you up |
@PushyPants Thanks for the reply, it has certainly reduced the number of errors. However, I still can't find the data I'm looking for. I'm trying to find the paged list of items, ie the 25 items that back the current page. The console.log(this.$refs) displays them as filteredItems if you drill into propPanelIter, but it's undefined if you console.log it at the same time. Interestingly, once you have started a search it is there. I'm caught between a rock and a hard place, I have list 12000+ items to display, I have a fairly nasty query to calculate 3 values to display on each of the 12000 items. So rather than running a really horrible back end query that gets the 12k with their 3 values I was hoping to page them and per page of 25 run 25 calls to get the extra 3 values. This is looking to be difficult to say the least, so I'm also looking at server side pagination, which would solve the issue, but of course then search goes out the window, and as you can imagine with 12k+ items, that is pretty important! |
@tompinnacle if I'm reading this correctly:
You probably don't need to reference refs at all. Both <v-data-table> and <v-data-iterator> have an event called 'current-items'. On mount it will fire and show you the first page and any time any of the items in a page change (or you paginate) it will fire again. If you're just looking for the data of the items on the current page, then you can get that this way: In the template
pleaseWork without the '()' will automatically pass the data through to your function. If you'd like to explicitly pass the data or need to add other parameters to your function you can use pleaseWork($event) and if need be, pleaseWork($event, param2, param3) in the script
|
You can sort, paginate, and filter server-side. I don't know why this issue has been left open for so long |
When I tried this, I was getting an error which said that |
Any news on this feature ? |
@current-items doesn't help as it shows only items on the page. More useful would be something like |
up |
It would be great that create @filtered-items |
Why was this closed? |
This worked for me:
|
|
@bob-lee any finding on that |
@PabloRN nothing new, my project still using v2 and it needed to find current items when pagination changes. Current items can be found by following above suggestion. |
@bob-lee thx for the prompt response. Well, I'm using vuetify 3 with vue 3 and I can't find anything related in the ref object. |
Problem to solve
How to retrieve (watch) the filtered Items from the searchTableItems function of a VDataTable?
For e.g. with
$refs.tableRefName.items returns all items of the table, although I filtered the Data Table Items using a standard search input field and seeing the filtered results with
"$refs.tableRefName.items" still contains all (unfilterd) items.
Proposed solution
I was hoping to find something like "$refs.tableRefName.filteredItems" or "$refs.tableRefName.searchTableItems" to retrieve the filtered Items but didn't.
Cheers Tim
The text was updated successfully, but these errors were encountered: