ratiw / vue-table

data table simplify! -- vuetable is a Vue.js component that will automatically request (JSON) data from the server and display them nicely in html table with swappable/extensible pagination component.
MIT License
1.83k stars 303 forks source link

How can i update vuetable with custom data ? #132

Open Nisthar opened 7 years ago

Nisthar commented 7 years ago

I have an ajax function where i get custom data from the server. So i already have some data on the vuetable. I want to manually refresh the table and add the custom data.

ratiw commented 7 years ago

@Nisthar If I understand you correctly, you would like to have vuetable using the data you've already retrieved via existing ajax function, right? If so, you cannot, vuetable will automatically load the data from the server via api-url prop. If I misunderstand your point, please explain more.

Nisthar commented 7 years ago

Yes, But in addition to the automatic ajax function of the vuetable, i want to manually do ajax and change the data of the vuetable.

Anyway, I accomplished this with another way. I changed the apiUrl prop of the vuetable and set it to new url which returns the custom data that i want (not the original data) and refreshed the table. So the table got populated with the custom data.

BTW is there any other way like manually setting the "tableData" with custom data and refreshing the table?

On Sun, Dec 4, 2016 at 11:56 AM, Rati Wannapanop notifications@github.com wrote:

@Nisthar https://github.com/Nisthar If I understand you correctly, you would like to have vuetable using the data you've already retrieved via existing ajax function, right? If so, you cannot, vuetable will automatically load the data from the server via api-url prop. If I misunderstand your point, please explain more.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ratiw/vue-table/issues/132#issuecomment-264687165, or mute the thread https://github.com/notifications/unsubscribe-auth/ALcELXTzpGvaD4lSWc5xTtBwzJYUOXOwks5rEl0xgaJpZM4LDS_B .

ratiw commented 7 years ago

@Nisthar There is actually another component called vueitems, but it serves different purpose than vuetable.

With vueitems you have to manually retrieve the data yourself and give it to vueitems to display. It is aimed to be part of a form input (think of invoice items), so many functionalities related to pagination, sorting are removed. However, I haven't put any documentation on the project, but most of the props and events are the same as vuetable. You just need to go through source code to learn about it.

nkostadinov commented 7 years ago

I also think there should be a way to set any data to the table. May be a callback function or event. There are many cases where you dont need to make an api call to display a table with some info.

zxc23 commented 7 years ago

Yes, absolutely. What about a prop to provide data to the table, and if it's not used, then use the API call (or vice versa - doesn't really matter)? I really want to use vue-table but this is a requirement for my needs.

maleta commented 6 years ago

I managed to reload vuetable for non-api table when data is changed in the background with this.$refs.vuetable.setData(this.data).