Tables are a core feature in data driven applications. Ubot Studio already helps you create html tables from csv files, but this requires constant refreshing of the Ubot browser to update the tables data. Do this a thousand times and you will annoy your users with a constantly refreshing browser window.
So how CAN we add data to a table without having to refresh the browser constantly? The answer is we use AJAX. But the problem is many of us bought Ubot Studio so we wouldn’t have to write code, so that doesn’t really help. There’s really no no-code solution to building bots. At some point you will have to dive into code, so we’ll have to compromise and find a solution that helps us without requiring you to become a full-blown coder. Since we CAN read tutorials and follow along with them, maybe there’s an AJAX script available that is well documented and easy to use…
This is an example I pulled from the example bot I mentioned above.
If you put that inside a loop and run it 1000 times you will likely crash the Ubot browser, so be aware. It works fine with a small wait of .1 seconds, but you may need more or less depending on your computer.
One Custom Command to Rule Them All
So far I’ve used Tabulator to build simple crypto price trackers, pricing tables and table tables. I made enough tables to get started on a custom command for creating tables easily. Now I can include one Ubot bot in other projects to get the table functionality bots so desperately need.
I do this by using the Include command and pasting the path to the .ubot file I’ve called Tabulator-Total.ubot. In my bots the include looks like this:
That Tabulator-Total.ubot project has all the custom commands and functions I need to easily build tables. With the include command I don’t have to clutter my bots with repetitive commands and functions, instead I leave them in a bot to then “include” in the bots I want it in.
This custom command is far from perfect, but it DOES let you add data on the fly. There’s still a lot to add to it. Tabulator is a large script, with lots of functions available that takes time to learn. Each function would ideally have it’s own function in the Tabulator-Total.ubot project… but it will take a lot of time to finish.
Here’s the parameters I have created in the Tabulator Total command:
- tableData – doesn’t work yet but will let you add load an entire table that you already have data for.
- tableColumns – define the column headers, separating column with a | (pipe).
- ColumnsWithDefinitions – this isn’t finished.
- ColumnsDefinitions – not finished.
- setGroupBy – lets you group by values. You can have table data show in presorted groups where each row in the group has a specific value.
- setGroupValues – not finished.
- setGroupStartOpen – set to true it will automatically start the table with all groups expanded. Set to false all groups will be collapsed.
- CRUDData – when set to add then data will be added to the table. Eventually I want to have it a remove parameter that will let you DELETE the row that you set in CRUDRow. The Pipes seperate the values for each cell, and they go in exactly the order they are in. There must be as many cells as their are columns, so empty cells would be || , which means the cell has nothing.
- CRUDDuplicates – set to true you can allow duplicate rows to be added. set to false then only unique rows will be added. VERY helpful!
With these customizable parameters the idea is to be able to quickly and easily create a table with the features you need. The end result will be a table that updates without having to refresh the browser.
Hopefully it gives you an idea of how you can integrate Tabulator into your bots!
The next steps for this project will be to flesh out the parameters to be more customizable.
When you open the Tabulator-Total.ubot project up you’ll find there is 1 main command called Tabulator Total and a couple functions that are used within that command. It’s sort of a mess but it works, and that’s all that matters right now.
Warning: Invalid argument supplied for foreach() in /home/actionreed/public_html/su/wp-content/themes/thrive-theme/inc/classes/class-thrive-theme-comments.php on line 463