I successfully added filters to the columns of my table, but now I want to be able to download the filtered data as CSV or just get the filtered data and create myself the CSV file.
I think one of these 3 options suits me (in order of preference):
Call the built-in download/export function using the template node. But I have no idea how to call functions of the ui table.
Send a command to request all visible data, if even exists. The quick info documentation only shows 3 commands. Where can I find the list of commands?
Have a callback function when the filters are applied. If someone has an example it would be great.
Only a quick answer to your point 2.
All you can do (commands, callbacks, parameters ...) are well documented @ tabulator website.
ui-table only acts as an interface.
I think everything you can do with tabulator should be doable through ui-table
Tabulator allows you to download/export the table data as a file directly from your browser, no server needed.
The download will contain the text values of all data currently visible in the table, matching the current column layout, column titles, sorting and filtering.
Hope this functionality already exists in 3.7 which is the version ui-table currently use.
Where can I find the export function command? The readme file only mentions addRow, replaceData or addFilter and says:
Beside data manipulation you can set filters and do many other things with commands.
I have tried sending commands getData, getFilters, getHeaderFilters and none of them works. I still don't know where to find the list if the supported commands, I am just assuming they are the names of the available functions.
Adding the callback function gives the error InternalError: too much recursion on the browser console and my data is fails to load. This is the callback definition I added to msg.ui_control.tabulator:
Thanks for the hints. Sorry for my lack of knowledge in JavaScript/NodeJS stuff.
I now have access to the data, but my requirements changed a little and now I need the applied filters. The problem is that the 'filters' parameter on the 'dataFiltered' and 'dataFiltering' callbacks are always zero length arrays. I inspected the 'rows' parameter but couldn't find the applied filters either. Am I doing something wrong?
Just found the get filters method from the rows elements. rows[0]._row.table.getHeaderFilters()
My programming experience tells me this is not a good practice, but my ignorance in JS makes me doubt about my first assumption.
sorry I do not have time to dig in deeper. Accessing prototype properties (_) directly is not "best practice", because if the implementations changes in the future you have the risk that your code could be broken. Best is to find a get method to access the properties you need.
this is the far i could understand on how to build the message to be sent to ui-table
msg.ui_control = {
"tabulator":{
"command":"download",
"arguments":[
{
"type": "csv",
"name": "feeder41.csv"
}
]
}
}