B4A Library [Class] Flexible Table

klaus

Expert
Licensed User
Longtime User
How do you draw borders and row lines? Is this using built in class/sub or you draw it manually?
These lines are not drawn, it is the space between the Labels in the ScrollView.Panel and the color is ScrollView.Panel.Color.
Is that possible to display data to users, just a few number rows that fits screen size, and display another data when users scroll it?
This is allready the case, See HERE in the original thread, The Lable content is updated when the user scrolls.
 

incendio

Well-Known Member
Licensed User
Longtime User
This is allready the case, See HERE in the original thread, The Lable content is updated when the user scrolls.

If I understood correctly, the label is reused and updated when user scroll.
This is not what I have in mind.

On class source code, Sub LoadSQLiteDB, all data retrieved and then add to row. Then Sub AddRow handle how many data need to display on screen.

What I mean here, Sub LoadSQLiteDB, retrieve only data that will display on the screen, and when users scrolls, data retrieved again. In this way (if this is possible,combine with this idea http://www.b4x.com/android/forum/threads/class-flexible-table.30649/page-12#post-250615), no matter how large the data is, I am sure it will always fast.
 
Last edited:

mat2175

Member
Licensed User
Longtime User
I want to remove the whole row that the user selects using a button click event. How would i go about this any examples would be appreciated.
Thanks.
 

Inman

Well-Known Member
Licensed User
Longtime User
I am trying to create a table with just 2 columns and 2 rows. I add the data manually using AddRow and NOT with one of the Load functions. While the header is created correctly and I see the status message at the bottom saying "2 rows", the table is empty without any rows. I am using v1.33. Any idea?
 

Inman

Well-Known Member
Licensed User
Longtime User
Ah yes I didn't do that. Now it works.

I didn't find it in the example, which is why I didn't add it. I was under the impression that it automatically sets the width based on table width and number of columns.
 

Reinierus

Member
Licensed User
Longtime User
Hello.
I am using the table in a panel with AHPageContainer and I get this error: java.lang.NullPointerException

I think that it is because there is a right order in the program lines to make the table works or the table doesn't work in the PageContainer.

Can someone tell me how to fix that? (I have lots of lines)

Best regards
 

luismora

New Member
Licensed User
Longtime User
It working with Panel. I'm just add


'Adds to Panel
Public Sub AddToPanel(Act As Panel, Left As Int, Top As Int, Width As Int, Height As Int)
visible = True
Header.Initialize("")
Header.Color = TableColor
Act.AddView(Header, Left, Top , Width, RowHeight)
Act.AddView(SV, Left, Top + RowHeight, Width, Height - RowHeight)
ColumnWidth = SV.Width / NumberOfColumns

SV_ScrollChanged(0)

End Sub
 

klaus

Expert
Licensed User
Longtime User
I suppose that you changed the code in the Table Class.
What version of the Table Class are you using ?
You don't need to modify the class code.
Use simply something like Table1.AddToActivity(pnlTable, 0, 0, pnlTable.Width, pnlTable.Height) in the calling activity.
In the AddToActivity routine Act can be either an activity or a panel.
In the recent versions of the Table Class there is also the AddToView routine which does the same.
 

Reinierus

Member
Licensed User
Longtime User
Hello Klaus.
I change to WebView table to show the data. If I need to use the Table Class, I will ask again.

Thanks.
 

luismora

New Member
Licensed User
Longtime User
Hello Klaus.

You have the right. I was using a very old version.

Thank you I saved me many days of works
 

stu14t

Active Member
Licensed User
Longtime User
I'm having problems with trying to delete the last row of the table. My app dynamically adds rows to the table as data is collected by the user. The user also has the function to remove the last row of the data input. Now that's fine if there are more than two rows. As soon as you get to the last visible row and press the Clear Last button I get an index error:
B4X:
The battery level is: 100
ShowRow: -1
Error occurred on line: 391 (table)
java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
    at java.util.ArrayList.get(ArrayList.java:310)
    at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    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:66)
    at android.view.View.performClick(View.java:4637)
    at android.view.View$PerformClick.run(View.java:19422)
    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:5586)
    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:1268)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
    at dalvik.system.NativeStart.main(Native Method)

Here is the code that implements the row delete and it works fine but for the last row remaining in the table
B4X:
Sub ButtonCL_Click
    Pen(TestPoint) = 0 ' This just removes the data that will be deleted from the array
    TotBlows(TestPoint) = 0 ' Same as above
    Dim Row1 As String
    If TestPoint > 0 Then ' This stops you going beyond the start of the table / array
        TestPoint = TestPoint - 1
        Row1 = CStr(TestPoint) 'Have to pass a string to the Table class
        Table1.RemoveRow(Row1) '
        lblResult.Text = ""
    Else
        Msgbox2("You Are at the Start of the Dataset","","OK","","",LoadBitmap(File.DirAssets,"Exclamation-icon.png"))
    End If
    'Display_upDate
End Sub

Any ideas I'm banging my head against the wall
 

klaus

Expert
Licensed User
Longtime User
In the Table class code change in the RemoveRow routine this code
B4X:
maxVisibleRow = Min(maxVisibleRow, Data.Size - 1) ' adjust visible rows
minVisibleRow = Min(minVisibleRow, Data.Size - 1)
For i = minVisibleRow To maxVisibleRow ' show all visible rows (should select the ones needed to be selected as well)
'If (IsMultiSelect OR sr = i) Then HideRow(i) ' in multi select we made too much mess, we need to redraw the whole view (can be optimized if needed!)
    ShowRow(i)
Next
by this one
B4X:
If Data.Size > 0 Then
    maxVisibleRow = Min(maxVisibleRow, Data.Size - 1) ' adjust visible rows
    minVisibleRow = Min(minVisibleRow, Data.Size - 1)
    For i = minVisibleRow To maxVisibleRow ' show all visible rows (should select the ones needed to be selected as well)
    'If (IsMultiSelect OR sr = i) Then HideRow(i) ' in multi select we made too much mess, we need to redraw the whole view (can be optimized if needed!)
        ShowRow(i)
    Next
End If
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Greetings, all. Thank you in advance for answering my question.

I have been working extensively with the Flexible Table Class. It is GREAT!!! Thank you, Klaus, for adding the valuable added functionality to the original Table Class. Thank you, Erel, not only for the original table class but also for the wonderful development environment of B4A and Melamoud for his participation in the Table Class.

Question:
Can I have a table with no header row? I have tried but to no avail. I can get a "blank" header row, but I want no header row.

Comment:
If a table is created with Addrows, Table RowColor2 cannot be changed. It works loading CSV and DB.

Best regards.

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