B4J Question [BANano/Skeleton] Is it possible to programmatically set the SKTable Column Titles?

LJG

Member
While we can set the BANano/Skeleton SKTable column titles in the Custom Properties of the Visual Designer, there does not appear to be a way to set the column titles via code. If there is a way to do that, please help, thank you.
 

nedium

Active Member
Licensed User
Longtime User
Hi,
There is not much information about the 'View' of BANano, a little help on its use and function would be good, then the creativity comes out on its own.
we are still waiting .. a greeting
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
@nedium Please make a new topic in the forum with the subject starting with [BANano] as this is a different question.

SKTable is a simple html table normally for presenting data and not an editable DataTable. But you could simulate this effect a bit. Note that being both clickable and editable may be weird.

B4X:
Sub BANano_Ready()
    
    Dim body As BANanoElement
    body.Initialize("body")
    
    ' some div where we can attach the table to
    body.Append($"<div id="mydiv"></div>"$)
    
    ' make a table and add it to the div
    Dim tbl As SKTable
    tbl.Initialize(Me, "tbl", "tbl")
    tbl.AddToParent("mydiv")
    ' set titles to make columns (3)
    tbl.Titles = "col1;col2;col3"
    
    ' add some rows
    For i = 0 To 10
        tbl.addrow(Array("a" & i, "b" & i, "c" & i))        
    Next
    
    ' get all the <td> tags from this table
    Dim allTDs() As BANanoElement = tbl.Element.Find("td")
    For i = 0 To allTDs.Length - 1
        ' make the column editable      
        allTDs(i).SetAttr("contenteditable", "true")
    Next
End Sub

' clicked event
Sub tbl_Click (event As BANanoEvent)
    ' get the clicked column
    Dim target As BANanoObject = event.Target
    
    ' get the value of the clicked column
    Dim value As BANanoElement
    value.Initialize("#" & target.GetField("id").Result)
    
    ' show a toast message with the value
    SKTools.ShowToast("Value clicked: " & value.GetText,"default", 3000, True)
End Sub

Alwaysbusy
 
Upvote 0
Top