GigaTables / reactables

GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems.
MIT License
144 stars 30 forks source link

Force refresh #85

Closed MichaelF77 closed 6 years ago

MichaelF77 commented 6 years ago

Is there a way to force reload from ajax API based on some external event or state, but not automatically.

arthurkushman commented 6 years ago

Hi, here is the only way to do that:

GigaTables plug-in has 2 types of triggers triggerBefore and triggerAfter which can be applied to any action button - Create, Edit or Delete.

an example of usage is in the settings config:

 tableOpts: {
   buttons: [
     {extended: "editor_create", editor: editor, triggerAfter: (function () {
         console.log('after create');
       }), triggerBefore: (function () {
         console.log('before create');
       })},
     {extended: "editor_edit", editor: editor},
     {extended: "editor_remove", editor: editor, triggerAfter: (function () {
         console.log('after del');
       })}
   ],
   buttonsPosition: ['top', 'bottom'],
   theme: 'std'
 }
MichaelF77 commented 6 years ago

I figured out how to force refresh using following snippet: reloadGrid() { loadData() .then( (data) => { let jsonData = data['rows'] ? data['rows'] : data['row']; // one row or several this.reviewGrid.jsonData = jsonData; this.reviewGrid.createTable(jsonData); this.reviewGrid.setTableSort(); }) }

Thanks for great work !