TableView class - problem

Caravelle

Active Member
Licensed User
Longtime User
I dare say we've all been there. You have something working nicely, you make a couple of changes, and suddenly a feature stops working and you don't know why :confused:. Can anyone see what I've done wrong please ?

I used the standard example as a template, making changes to load the table from a pre-existing sql database table. Initially, the CellClick and HeaderClick subs worked nicely but now, after a little "tidying up" of my code, nothing happens when a header is clicked, and when a cell is clicked all that happens is that the line is highlighted. The data loads into the table nicely, everything is fine except that the two cellclick subs at the end no longer seem to function properly. Presumably I have deleted something I shouldn't have but I've been staring at the screen and print-outs of different versions for some time, and I just can't see what is wrong or even where the trouble is likely to lie.

Here is my code:

B4X:
Sub Process_Globals
   Dim SQL1 As SQL
End Sub

Sub Globals
   Dim TableLog As Table
End Sub

Sub Activity_Create(FirstTime As Boolean   
   If FirstTime Then 
      SQL1.Initialize("Removable/MicroSD/Aviation/", "AvData.sqb", False)
   End If   
   
   TableLog.Initialize(Me, "Table1", 14)
   TableLog.AddToActivity(Activity, 0, 0dip, 100%x, 50%y)   
   TableLog.SetHeader(Array As String("_id", "Serial", "Maker", "Type", "SubType", "Name", "Msn", "Check", "OpCode", "Operator", "Location", "Date", "Notes", "Extra"))
   TableLog.SetColumnsWidths(Array As Int(100dip, 100dip, 100dip, 100dip, 100dip, 100dip, 100dip, 20dip, 40dip,150dip,50dip,80dip,100dip,100dip))
   
   Dim Cursor1 As Cursor
   Cursor1 = SQL1.ExecQuery("SELECT * FROM Log WHERE Type LIKE 'A320' ORDER BY _id")
   For x = 0 To Cursor1.RowCount - 1
      Cursor1.Position = x
      Dim TableMap(14) As String 
      For i = 0 To Cursor1.ColumnCount-1
         TableMap(i)=Cursor1.GetString2(i)
      Next
      TableLog.AddRow(TableMap)
   Next
      Activity.Title = x & " records found."
   Cursor1.Close
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub TableLog_CellClick (Col As Int, Row As Int)
   Log("CellClick: " & Col & " , " & Row)
   Activity.Title = TableLog.GetValue(Col, Row)
End Sub

Sub TableLog_HeaderClick (Col As Int)
   Log("HeaderClick: " & Col)
End Sub

And in case the problem lies in the version of the class file I'm using I've attached my complete program as a zip. I can provide a small database if necessary. The original is 40 megabytes with several tables. The query above retrieves about 1800 records.

Many thanks

Caravelle
 

Attachments

  • TableLog.zip
    10.9 KB · Views: 165

Caravelle

Active Member
Licensed User
Longtime User
Once again, the answer magically appeared 20 seconds after I posted this.

TableLog.Initialize(Me, "Table1", 14)
should be
TableLog.Initialize(Me, "TableLog", 14)

:sign0161:

Sorry to have bothered you !

Caravelle.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
something like this

B4X:
Sub Table1_HeaderClick (Col As Int) ' col = column index - take the colums where all numbers are
  If Col = 5 Then
  sorter
  End If
End Sub
 
Upvote 0
Top