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

need manual refresh button #103

Closed wangfrombupt closed 6 years ago

wangfrombupt commented 6 years ago

I know there is auto refresh function in GT, but I really need a manual refresh button which can get table data from the server only when users click it. One of my tables is created dynamically, thus it takes about half a minute to get its data. With auto fresh, there will be lots of unnecessary gets. So I think it is reasonable to let the user choose the right time to get the data from such tables. Would you please add such a refresh button option in GT?

arthurkushman commented 6 years ago

For me it is easy to add, especially optionally, anything. Let me understand your needs - how the button differs from F5 or reload button in browser? May be in your particular case there is no such abilities (probably you make browser tools invisible)? If not so, what's the matter then. Can't see the point here, sorry for that.

arthurkushman commented 6 years ago

So could u explain in more detail, please?

wangfrombupt commented 6 years ago

Thanks for your attention. There are three differences between the reload button of the browser and the customizable refresh button of GT:

  1. With a refresh button of GT, the semantics of the operation is more clear: It aims to update the content of GT, not the whole web page (which is what the reload button aims to do), thereby only an HTTP request for the table content (instead of the whole page) needs to be sent;
  2. When users access the app from mobile phone, the toolbar of the browser is sometimes invisible. Although it can be configured to show up, the users would complain about such inconveniences, which lead to a poor user experience;
  3. I can customize the behavior of the refresh button of GT. In my current project, the actual behavior of the refresh button is not just getting the table data, but also regenerating the back end database table before getting its data. But for the reload button, it's not straightforward to implement such a function.

So, please add the optional refresh button to GT. Thanks a lot.

arthurkushman commented 6 years ago

Now you can add reload button to any position of std buttons - see example in main.js, it is only reloading content of a table without the need to reload other components. Patch - https://github.com/GigaTables/reactables/releases/tag/2.4.3

Thomstrong commented 6 years ago

We just have time to test the reload button, but found it didn't work as expected. We want the reload button to request a new url other than the GT's default url in settings. And we also want the reload button has triggerAfter and triggerBefore functions like other buttons, but it seems that those functions are not supported. The following are the snippets of our code for using reload button. Please fix this issue. Thanks.

let editor = {
    ajax: {
        reload: {
            url: '/update_radar',
            type: 'GET',
        },
    },
    tableOpts: {
        buttons: [
            //TODO
            {
                extended: "editor_reload", editor: editor, triggerAfter: (function () {
                    alert("刷新完成!")
                }), triggerBefore: (function () {
                    alert("刷新需要半分钟左右,请耐心等待...")
                    userService.updateRadar()
                })
            }
        ],