08 March 2016
Updated: New features added to the Business App sample
The Corona Labs Business App sample project has been updated with some frequently requested “How do I do this?” examples. A new data tab (and menu item) have been added for you. This new scene offers:
- a tableView populated from selecting data from an SQLite database
- tapping on a tableView row lets you edit the record and store the changes
- tapping on the “Add” button lets you add new records to the database
To support these changes, a database abstraction module has been added that provides initialization of the database and basic CRUD operations (Create, Read, Update, Delete) for records in the database.
As part of the solution, you create a Lua table that defines your database scheme and the module will use that table for it’s operations.
Both the Update and Add screens provide examples of using native.newTextField’s to input data and write to the database.
The code that populates the tableView
uses MVC (Model, View, Controller) best practices to separate the data from the display.
The tableView's
insert
function provides the controller aspect so your onRowRender()
function knows about it’s record and doesn’t have to know anything about how your data table is constructed and ordered.
Additionally a bug was fixed in the tableView
refresh code to handle a case where your tableView
didn’t have enough records in it and you tapped below the last record.
Download these new features today by visiting the project on the Corona Labs github repository. See how it can help you develop business style apps.
Kiffin Ayers
Posted at 11:45h, 08 MarchGreat addition! Thanks!
John
Posted at 17:26h, 08 MarchAnother great addition would be a built in search bar on the tableview widget 🙂
Rob Miracle
Posted at 18:22h, 08 MarchI’m considering adding that in a future version however, I can’t take away all the fun for you 😉
Marcus
Posted at 17:44h, 08 MarchIt will be really nice to show how to do a swipe to delete a row. This is a pretty common operation for a business app.
Rob Miracle
Posted at 18:22h, 08 MarchGood idea.
Yang
Posted at 19:13h, 08 MarchHey Rob,
I think a good addition to the business app would be the possibility to add an account and sign in with it (using a local database) in order to show another screen, which would also cover password encryption.
Of course this might not be necessary if there already is a sample for this, I just can’t seem to find one.
Kerem
Posted at 15:56h, 10 MarchGreat work Rob. I like the idea of a CRUD abstraction module. Keep it up!
brindleware
Posted at 10:00h, 14 MarchHow about a coronium version?
Rob Miracle
Posted at 16:11h, 14 MarchI will probably do that once we release the Coronium based Corona Cloud.
Paul
Posted at 12:25h, 17 MarchGreat timing, I needed a business app example. 🙂 Thank you!
vikas
Posted at 07:29h, 05 AugustHi Rob.. Thanks for adding great features in the updated version. I’m new to corona and learning lua. I just want to ask that how do I add a ‘Delete’ button on ‘edit account’ screen just like ‘Submit’ button to delete that record from database’. Thank you!
Rob Miracle
Posted at 09:17h, 05 AugustThis is a question best asked in the forums: https://forums.coronalabs.com/
We are going to need to see and show code and code doesn’t work well in blog post comments. Please ask your question in the forums.
Rob
vikas
Posted at 12:33h, 05 AugustThanks for your reply Rob. I’ve posted that question on the forum – https://forums.coronalabs.com/topic/64942-deleting-a-record-from-the-database-in-corona-sample-app/