MicroDroid / vue-materialize-datatable

A fancy Materialize CSS datatable VueJS component.
https://overcoder.dev/vue-materialize-datatable
MIT License
179 stars 67 forks source link

Server Search Issues #45

Closed carlosdico closed 4 years ago

carlosdico commented 4 years ago

I'm having problems with the server side search. I'm using Vue.js and when I start a search, the callback is called but in a loop. Y need to delete the letter introduced in the search input to stop the calls to the server.

How can I fix it?

Thanks.

MicroDroid commented 4 years ago

Please provide your code

carlosdico commented 4 years ago

Sure This is my datatable

<DataTable :title="title" :exportable="false" :printable="false" :columns="columns" :rows="rows" :serverSearch="true" :serverSearchFunc="serverSearchFunction" locale="es"> </DataTable> And this is the script that load and update the datatable

``

Thanks

MicroDroid commented 4 years ago

Try replacing this.rows only when response.data is not exactly same as this.rows.

I suspect that when you replace this.rows, internal processedRows computed property does get called again which re-triggers the callback.

@shafiqueqadri This is a bug though, can you please verify my suspicion and fix that?

carlosdico commented 4 years ago

Thanks MicroDroid,

I add this code to the function if(JSON.stringify(this.rows) != JSON.stringify(response.data)){ this.rows = response.data; }

This fix the problem with the multiple calls but now I have an error with the paginatedRows

`[Vue warn]: Error in render: "TypeError: paginatedRows is undefined"

found in

at node_modules/vue-materialize-datatable/src/DataTable.vue at resources/assets/js/components/user/UserList.vue at resources/assets/js/components/App.vue `
MicroDroid commented 4 years ago

Interesting, I'll take a look myself asap

On Thu, Oct 24, 2019, 11:01 AM Carlos notifications@github.com wrote:

Thanks MicroDroid,

I add this code to the function if(JSON.stringify(this.rows) != JSON.stringify(response.data)){ this.rows = response.data; }

This fix the problem with the multiple calls but now I have an error with the paginatedRows

`[Vue warn]: Error in render: "TypeError: paginatedRows is undefined"

found in at node_modules/vue-materialize-datatable/src/DataTable.vue at resources/assets/js/components/user/UserList.vue at resources/assets/js/components/App.vue `

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MicroDroid/vue-materialize-datatable/issues/45?email_source=notifications&email_token=ACBA277JVHFGUBCPWAIGZLTQQFI6FA5CNFSM4JEFO3NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECEDGDA#issuecomment-545796876, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBA27YCJFMQNI4TGFYZKKLQQFI6FANCNFSM4JEFO3NA .

MicroDroid commented 4 years ago

Should be fixed now!