Closed noru closed 8 years ago
@noru The event in Vue.js is not asynchronous, so you cannot rely on that. It only signifies that the event has occurred. Why would you want to intercept the data like vue-resource?
@ratiw The reason I wanted to do so is that, my api doesn't have sufficient "pagination" format and I can't change that internally. It is like:
{ found: 50 start: 0, hit: [ ...{row data array}... ] }
so I have to calculate a legal 'pagination' object and attach it to the original response.
Of cause, I've already done it through vue-resource, but I don't think it is the best place to be. It would be better if such logic is contained by my table component.
I found vue-table is unique in that it feeds itself from API directly, while other table components often have a "row data" sort of property as data source. Can vue-table support that? If not, I think it is a viable requirement for a user may not always have an API or he wants to control/manipulate the data himself (sorting, filtering, etc.)
@noru I see. I was thinking about adding the data transformation before, but not yet come across any project for that yet.
It's possible and wouldn't be that hard to implement but I'm afraid I will not have time to work on it right now as I'm quite busy and only able to answer short questions here and there.
If you cannot wait and interesting in implementing it, I can point you to where it should be implemented. And maybe send your PR, once you get it working.
@ratiw yeah sure, be glad to. shed me some light and I'll see what I can do.
@noru This is where the requested data was successfully retrieved and set to tableData
.
You should call a user-defined method in the parent instance (perhaps named it transform(response.body)
) to do the transformation and returns the return to be set to tableData
.
Thanks @ratiw, already in use!
I using this event callback to intercept response to set correct pagination data.
However, during my try I found that didn't work because the table row rendering seems already done before my interception.
In my understanding, it should be called right after the data was returned (before it flows into vuetable).
What's your opinion on that? Plus, I want to ask if there is a way of interception just as vue-resource provided.
Thanks for the work!