Data-Table: Import CSV, Run Timers, Inline Editing & RealTime Updates, Export to Excel & PDF
Download BVAD3 7.15+
Hi there, this project was inspired by a question I saw in the b4x forum. The purpose is to parse a csv file and load it to a data-table. Then we set up timers that will change the random number to any number. To demonstrate this, we have set the random numbers to be black outlined chips. When a value is changed, we assign a random color to it. Depending on the mode, between easy, difficult and impossible, the timers fire depending on the set intervals.
For this example, we are just updating the first page that contains 50 records and not everything. As you have noted, easy, is slower whilst impossible, is fastest in terms of changing the values. We later export the contents to PDF and also Excel.
When we refresh the contents, we are able to start from the beginning as we reset everything and stop the timers. We are also able to perform inline editing as we have set the column types to be text fields.
Let's jump to the source code.
We have created a layout with 2 rows. The first row has our buttons and the second row, our data-table.
We have specified some properties of the data-table that will address our csv file. All the columns should be lowercase and should not have spaces. We have updated our csv file to ensure it meets this requirement.
We specify the columns in the csv file. The first row of the csv file contain these headers. We also want the color of the random number column to be computed, from a callback.
The random number column should be displayed as a chip, the other columns should be text fields, so that we can edit them inline.
We specify the intervals for the timers, from easy to impossible.
When the page is mounted, we want to scan the csv and load it to the data-table.
The start timers call will fire the respective needed timer, depending on the selected mode.
The timer gets a random number between 0 and 50, generates a random number, then updates the row position chosen with the new random number. It also updates the changed property. This changed property is used to change the color of the changed random number to a random color.
We then click the buttons we need to set the update mode of the data-table, so that we can see reactive changes in real time.
We also added functionality to export the data-table to excel and pdf. Thats all for now. Thank you.