B4J Question Set columns and data to TableView which is on another form

Asdominik

Member
Hello everyone,
I am a new user of B4J application and I encountered a problem.

I have a Mainform from which I call a new form "frm_Load" via a button and set its properties and also assign layout "lyt_Load".
I can assign text properties to labels and text fields on new frm_Load. But I can't specify TableView columns and data.
I got an "Unknown Member SetColumns" error.

Here is my code:
DataView:
Sub btn_LoadProc_Click
    'Load frm_Load
    frm_Load.Initialize("frm_Load",1004,580)
    frm_Load.Title = "Load procedure"
    frm_Load.SetFormStyle("UNDECORATED")
    frm_Load.RootPane.LoadLayout("lyt_Load")
    frm_Load.Stylesheets.Add(File.GetUri(File.DirAssets, "Buttons.css"))
    lbl_LoadCaption.text = "Load procedure"
    
    'Here i got error
    'DataView "tbl_LoadData" is declared in Process_Globals As B4XView
    'DataView is placed in Pane on Layout lyt_Load
    
    tbl_LoadData.SetColumns(Array As String("Procedure", "Description")
    
    frm_Load.ShowAndWait
End Sub

Thanks for your help.
 

Asdominik

Member
Thanks for the reply.

To begin with, I didn't know that I had to define the application as B4XPages for this type of application. I took "UI" option as User interface. My mistake.

Log returns response : javafx.scene.control.TableView

I noticed on your TableView Tutorial post that I have to insert #Region Helper Methods procedures and the javaObject library, but the error remains. At the same time, I noticed that in your case you are not using the jXUI library.

If I remove the jXUI library, the "tbl_LoadData.SetColumns" error disappears, but then I can't access the objects on the other form. When declaring "Private tbl_LoadData As B4XView" I get the error "Unknown type B4Xview. Are you missing library reference" .

Since everything is difficult to describe, I am attaching the application for review. I'm doing something wrong but I don't know what 🤯.
 

Attachments

  • SCD-40.zip
    74.5 KB · Views: 58
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem in your project is that you declare tbl_LoadData As B4XView.
In that case, the SetColumns method is not recognized.

You can replace this line :
tbl_LoadData.SetColumns(Array As String("ID", "Value"))
by this one.
tbl_LoadData.As(TableView).SetColumns(Array As String("ID", "Value"))

And this line:
Dim row() As Object = tbl_LoadData.Items.Get(RowIndex)
by this one.
Dim row() As Object = tbl_LoadData.As(TableView).Items.Get(RowIndex)
 
Last edited:
Upvote 0

Asdominik

Member
Dear mr. Klaus,

now everything works as it should. Thank you very much for your help.

Since I'm new to the B4J application, I still don't fully understand how everything actually works, or what things mean and how they depend on each other.
With the 100th program, it will be a little clearer for me ;).

Thank you and greetings from Slovenia.
 
Upvote 0
Top