Hi @huarong and welcome to the forum,
Some admin:
I moved the question to a new thread since it was a new question
when formatting code it’s helpful to use code formatting markdown
```javascript
// insert your code here
```
For Tabulator specific questions it’s usually best to visit the github discussions page here and ask the question there.
One of the motivating factors for upgrading tabulator was to make this sort of thing doable and straight forward.
It isn’t supported - and won’t be supported in version 1.
Worth noting that Tabulator v2 currently uses Tabulator JS version 5.1 and when reading tabulator.info documentation you should switch to whichever version is currently being used by the Anvil Tabulator dependency.
downloadEncoder
isn’t available in Tabulator JS v5.1 but downloadReady
is and is probably sufficient.
(I am planning to upgrade to version 5.3 but haven’t got round to finishing that)
(Tabulator v1 uses Tabulator JS v4.6)
In Tabulator v2 your code will look something like this:
from tabulator.Tabulator import Tabulator
Tabulator.modules.add("Download")
Tabulator.modules.add("Export")
class Form1(Form1Template):
def __init__(self, **properties):
...
self.tabulator.options = {
"download_ready": self.download_ready
}
def download_ready(self, contents, blob):
# contents - the unencoded contents of the file
# blob - the blob object for the download
# custom action to send blob to server could be included here e.g.
anvil.server.call("save_download", anvil.js.to_media(blob))
# must return a blob to proceed with the download, return false to abort download
return blob
def button_1_click(self, **event_args):
"""This method is called when the button is clicked"""
self.tabulator.download("csv", "data.csv")