B4A Library [Class] Flexible Table

LucaMs

Expert
Licensed User
Longtime User
1) it is not difficult to change the class for this;
2) for this, the class must be changed much;
3) the class is suitable for displaying data, not "controls" (views). For this you can use CustomListView or CheckList.
 

klaus

Expert
Licensed User
Longtime User
1) Not implemented, always centered. You could change this line L.Gravity = Gravity.CENTER in the SetHeader routine.
2) As the cells are Labels, no images.
3) The Table class is inteded to display data in a table. You might use a CustomListView or UltimateListView.
 

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I still do not understand exactly what it is that loop.
I left it in comment. Now it works perfectly, as before, but much faster.
B4X:
Private Sub innerClearAll(vNumberOfColumns As Int)
    ...
    ...       
'    For i = 1 To 80 'fill the cache to avoid delay on the first touch
        LabelsCache.Add(CreateNewLabels)
'    Next
    ...
    ...
End Sub
 

adjie

Member
Licensed User
Longtime User
Hi Klause,
I've been playing around with this class and it help me a lot.
Now my question is, why it clear the content when I rotate the phone ?
how to keep the rows when it's change orientation ?
Thanks before.
 

Robert Grabowski

Member
Licensed User
Longtime User

Did anyone reply to this post? I am experiencing the same issue. I am using the Table module version 1.36. The SetHeader function produces visible column headings, but the .addrow function produces nothing visible. Version B4A4.0 produced results. I am currently trying to use B4A4.3 I stepped through the table code during .addrow and saw that it processed all the rows and columns. I could see my data values in the code. The status line appears and shows the number of rows processed. Nothing else appears in the resulting table. How do we make added rows visible using the Table module?

<code>
Sub btnHistory_Click
Dim csrPitTag As JackcessIndexCursor

DisableControlsForPanels
lblRFIDValue.text = txtTagRFID.Text

pnlTblHistory.RemoveAllViews
tblHistory.Initialize(Me, "TableHistory", 5, Gravity.LEFT, True)
tblHistory.CellAlignment = Bit.OR(Gravity.LEFT, Gravity.CENTER_VERTICAL)
tblHistory.AddToActivity(pnlTblHistory, 0, 0, pnlTblHistory.Width, pnlTblHistory.Height)
tblHistory.SetHeader(Array As String("DATE", "AGE", "WEIGHT", "SCORE", "PASTURE"))

idxCapture.Initialize(tblCapture.GetIndex("Pit Tag RFID"))
csrPitTag.Initialize(tblCapture.GetTable, idxCapture.GetIndex)
Dim Found As Boolean
Found = csrPitTag.FindFirstRowByEntry(Array As Object(txtTagRFID.Text))
'First Row
If Found Then
DateTime.DateFormat="MM/dd/yyyy"
tblHistory.AddRow(Array As String(DateTime.Date(Access.DateToTicks(csrPitTag.GetColumnValue("Date"))), csrPitTag.GetColumnValue("Age"), csrPitTag.GetColumnValue("Weight"), csrPitTag.GetColumnValue("GBC"), csrPitTag.GetColumnValue("Pasture")))
Found = csrPitTag.FindNextRow("Pit Tag RFID", txtTagRFID.Text)
Do While Found
tblHistory.AddRow(Array As String(DateTime.Date(Access.DateToTicks(csrPitTag.GetColumnValue("Date"))), csrPitTag.GetColumnValue("Age"), csrPitTag.GetColumnValue("Weight"), csrPitTag.GetColumnValue("GBC"), csrPitTag.GetColumnValue("Pasture")))
Found = csrPitTag.FindNextRow("Pit Tag RFID", txtTagRFID.Text)
Loop
Else
tblHistory.AddRow(Array As String("No prior history", "", "", "", ""))
End If

pnlHistory.BringToFront
pnlHistory.Visible = True

End Sub
</code>
 

metzeller_2013

Member
Licensed User
Longtime User
@Robert Grabowski, I also did not succeed in using the add row function.... What I did is saved the records in a sqlitedb then cleared my flexible table if it's populated then repopulate it using the LoadSQLiteDB function. I don't know if this applies to your app....
 

Robert Grabowski

Member
Licensed User
Longtime User
I use the Table module extensively with SQLite databases. It correctly loads and displays rows with the LoadSQLiteDB function. I have a case where I need to load it with data from a Jackcess table which requires using the .addrow function. The code I posted worked as late as December 2, 2014. I am trying to determine if it was one of the 3 Android updates or the 2 B4A updates that changed this functionality. In any case, data posted with the .addrow function will not appear in the table. Column headings and the status line are visible for affected tables.
 

Robert Grabowski

Member
Licensed User
Longtime User
I have tested the Table module version 1.38 with my existing code and it now displays rows added with .addrow().

Thank-you Klaus for your quick turnaround on this.
 

stanks

Active Member
Licensed User
Longtime User
hi

when i run example on device i get errs:

B4X:
** Activity (main) Create, isFirst = true **


table_setcellalignment (B4A line: 1435)


cAlignments(i) = cAlignment
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0


    at b4a.example1.table._setcellalignment(table.java:3614)
    at b4a.example1.main._activity_create(main.java:408)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at b4a.example1.main.afterFirstLayout(main.java:98)
    at b4a.example1.main.access$100(main.java:16)
    at b4a.example1.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5158)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0


** Activity (main) Resume **


java.lang.RuntimeException: Object should first be initialized (Map).


    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
    at anywheresoftware.b4a.objects.collections.Map.ContainsKey(Map.java:120)
    at b4a.example1.table._selectrow(table.java:3546)
    at b4a.example1.main._activity_click(main.java:338)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77)
    at android.view.View.performClick(View.java:4438)
    at android.view.View$PerformClick.run(View.java:18439)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5158)


    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Object should first be initialized (Map).

first err is when i run example (in class), and second is when i tap on activity
i use b4a v4.00 and device is android v4.4.4

thanks
 
Last edited:

Yafuhenk

Active Member
Licensed User
Longtime User
Hi,

Is it correct that changing cAutomaticWidths from False to True doesn't make any differance.
Same applies for changing Table1.AddRow to Table1.AddRowAutomaticWidth.
I don't see any difference although the text in the columns is different in length.

I think I doing something wrong or don't understand the way of using it.

Any help is appreciated

Thanks

Henk
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…