Android Question Has anyone created Data-Aware views?

Widget

Well-Known Member
Licensed User
Longtime User
In Delphi we have what is known as Data-Aware controls. A Delphi control is like a B4X view.

This makes working with databases soooo much easier. The data-aware controls (DAC) are almost identical to their non-data-aware control except they have a few data related properties like Datasource, FieldName.

All of the retrieving of the table data and filling in the field values to the DAC's are done automatically whenever the table is opened or moved to a different record, or a new record is added or deleted. In other words, any CRUD operation done to the Table will automatically update the DAC's that is connected to that table (via its Datasource property). A Datasource is an intermediary non-visual control that points to a Table. This allows the Datasource.Table property to be changed and switched to a different table (or database) without modifying the DAC properties. (Example: If we have 2 dozen DAV's on the screen and we need to change that table from Cust to Cust2, we don't need to update 2 dozen Viewsx.Table properties from "Cust" to "Cust2". We only update the Datasource.Table property from "Cust" to "Cust2". This makes the screen easy to maintain when we swap out similar tables, even those tables from different databases (with similar table fields).)

Why can't this be done in B4x? Or has it been done? Or is there a reason why it can't or shouldn't be done?

TIA
 

Widget

Well-Known Member
Licensed User
Longtime User
I'm surprised no one has replied. I thought data-aware controls would be a fantastic idea because it greatly reduces the amount of coding when retrieving and storing data using a UI. Am I missing something?
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
Why don't you create a lib for us? :) To be honest: I never needed that type of control. Ok, it's easy to use but I always needed an "extra" like more control over the data, etc.

I am considering writing it. But I wanted to know if it had been done before, or if anyone had any reasons as to why it won't work with B4A.
As far as getting more control over the data, the TTable has events for modifying the data when it is retrieved or before it is stored back to the table.

I just thought it is an obvious solution (at least to Delphi programmers) to execute a TTable.Next to retrieve the next row from the table, and it automatically updates all of the views that are linked to the TTable for the row that was retrieved. A call to a single method eliminates writing B4A code for every view that displays table data. Same when saving a record, it will retrieve all of the current view values and will save them back to the table if any of them were changed just by calling a single method TTable.Post.

This might be overkill if you're just displaying 2 or 3 fields from a table, but when there are 6 or more fields, it will eliminate a lot of global variables and code to keep them in sync to the table. I'll mull it over some more and see what I can come up with.
 
Upvote 0
Top