ratiw / vuetable-2

data table simplify! -- datatable component for Vue 2.x. See documentation at
https://vuetable.com
MIT License
2.15k stars 399 forks source link

sort with ApiMode = false #138

Open cpfarher opened 7 years ago

cpfarher commented 7 years ago

it is not support sort and filtering with ApiMode= false ?

ratiw commented 7 years ago

@cpfarher Not at the moment.

SeoRoman commented 7 years ago

Checking on this as I ran into the issue using VueX as well...

I was going to utilize the: getSortParam: function(sortOrder) { console.log(sortOrder) }

to access the object and sort my own data array, however I noticed that in api-mode = false it just states that "Data Mode Array" and no data is being sent. If that could send the same object even if data mode is false, then this would suffice :D just tossing 2 cents out there

ratiw commented 7 years ago

@SeoRoman Have you check out this codepen. I'm not sure if it's what you're looking for.

In Data mode, the (chunk of) data is supplied directly to Vuetable, so it never assume to manipulate those data directly because it never assume that the whole data is given. That means the sorting and filtering is likely to produce incorrect result. But you can use external library like lodash to manipulate the data before giving to Vuetable. Vuetable will only help conveying user intention/interaction back to your code to be handled appropriately as you see fit. This is demonstrated in the above example.

I, personally, think the Data mode is not fluent as it should be and hope to improve it, but, somehow, constraint by the current responsible work.

michaelschofield commented 7 years ago

Hey there. Seeing that this was last commented 6 days ago I just wanted to slide-in to echo my support and enthusiasm for sorting with the data prop : ).

I'm fresh to using your component but it looks like the most robust and best-documented out there, so I'm excited to dig in.

I haven't fully absorbed the docs yet so I'm not sure it's possible, but in my use case the data is already present in state so I am passing it to the datatable component through a prop, and I was thinking that if I could control the click events on the table headings I could just toggle between my getters in Vuex, which can handle the sorting.

I am doing this already outside of the component with a dropdown, but I think filtering from the headings feels more conventional.

mathiasleroy commented 6 years ago

+1

Isn't there an event fired when a header is clicked ? The class already changes when hovered, we just need the sortOrder icon and then we could use an event to trigger a sort in a computed function