B4J Library Master Details Using EditableTableView with CRUD

Hi there..

A new library is now available here..

This is a series in an article about the MashPropertyBag.

This has grown a lot, version 1.05 is now available and this library has now three facets as discussed in this post. The video below is about this functionality.


Ta!

Older stuff...

Well this is my first b4j library.

Problem Statement
I'm designing forms with master detail functionality using a ListView and a TableView with CRUD functionality. I realized that I will have multiple controls in the screen and this will make my code a little hard to maintain with the many Create, Update and Delete functionality. Thus this is a customview that is made with another customview. So with this all I need to use are the events and the resulting output and nothing else.

How this works?
  • The ListView (on left of screen) will record all your PrimaryKeys for your records
  • The EditableTableView (on right of screen) will be a section to edit any record you select on the listview.
  • Add Button - create a new record
  • Update - update an existing record
  • Delete - delete an existing records

Input (optional)
  • One can load a List with embedded maps to the list
  • One can load saved records from a specified folder

Output
  • Each record is saved on a folder you specify with SetFolder (inside Dir.App)
  • The JSON string of all records i.e. List with Maps inside is returned (I want to save this as is)

Events
  • ItemSelected - when a listview item is selected, a json record is returned
  • ItemDeleted - when an record is deleted via the button click
  • ItemUpdated - when a record is updated via update click
  • FileSelected - when a file is selected if a FilePicker is added

To Do
Many other fun playable stuff ;)

Lessons Learned
When creating a B4J library, your assets e.g. files should be "zipped", renamed to jar and copied to your external libraries folder before you compile your library. These are then referenced with #AdditionalJar: ETVFiles.jar in my case

Things to figure out
  • How to get the custom view to show in designer and some other things about my ETV
  • How do I properly comment my code for the XML library output.

MasterDetail.png


PS: I have included the library here for learning purposes for others, please bear in mind, this is my first attempt at this. You can compile the library yourself or just use the attached version.

Rem: Compile ETV to library with Project > Compile to Library

Credits:
This uses @rwblinn , ButtonTextField component for the FilePicker

Enjoy..
 

Attachments

  • ETV Example.zip
    5.6 KB · Views: 587
  • ETV.zip
    21.8 KB · Views: 642
  • ETVLibrary.zip
    28.5 KB · Views: 586
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Added some few functionality to detect control events, e.g. combobox.

B4X:
Sub etvImageSlider_ComboChanged (Property As String, Value As Object)
    Select Case Property
    Case "tablename"
        Dim sTable As String = Value
        sTable = sTable.Replace("null","")
        If sTable.length > 0 Then
            Dim xl As List = modABMaterial.GetFieldNames(sTable)
            etvImageSlider.SetPropertyList("ImageField", xl,False)
            etvImageSlider.SetPropertyList("TitleField", xl,False)
            etvImageSlider.SetPropertyList("SubTitleField", xl,False)
        End If
    End Select
End Sub
 

Attachments

  • ETV.zip
    24.2 KB · Views: 487
Top