B4J Question [SOLVED]How to set 4XBTable Next/Prev Arrows to Enabled?

Mikelgiles

Active Member
Licensed User
Longtime User
I am using two B4XTables on two different windows. The first table works as expected with the arrows enabled as the default. But the table on the second window has the arrows disabled(gray and unusable). The closest thing I find is ArrowsEnabledColor and ArrowsDisabledColor and have not found anything searching the community. I assume that enabled would be the default. Any hints on what to look for?
 

Mikelgiles

Active Member
Licensed User
Longtime User
The arrows should be enabled and disabled automatically. Are you sure that there is more than one page of data?
After adding a module for the second window and after creating a new layout the arrows were still disabled. I finally figured out the problem was caused by having only one record in the csv file when originally loaded. The real data is created by a import process which imports just under a thousand records. It looks like whatever controls the automatic graying of the arrows only uses the number records that were loaded when SetData was called rather than the current record count. After calling the SaveCSV process and restarting the app so the app starts off with the full data set the arrows work as expected. Will it be possible to make the arrows work with current records rather than what was in effect when SetData is run?
 
Upvote 0

Mikelgiles

Active Member
Licensed User
Longtime User
How are you updating the table data after you set it with SetData?

It is possible to do but you should do it correctly.

Here is the code importing and updating the sql DB. Subsequent imports will be much smaller after I add a few lines of code to eliminate duplicates. Setdata is done at program startup in the second module called from the main module. ImportTransactions is in a second module and called from the main module at users discretion. I have included the entire sub and marked the section that actually updates the DB. My desire is to do it correctly so let me know.

B4X:
Sub Process_Globals
    Private fx As JFX
    Private frmDetail As Form
    Private B4XTableD As B4XTable
    Private btnNext As Button
    Private btnPrev As Button
    Private su As StringUtils
    Private qfxData As String
End Sub


Sub ImportTransactions
    Dim qfxFile As TextReader
    qfxFile.Initialize(File.OpenInput(Main.dirDownloads, "Checking1.qfx") )
    qfxData = qfxFile.ReadAll
    Dim ORG As String = ParseQFX(Array As String("/SONRS","/FI","ORG"))
    Dim FID As String = ParseQFX(Array As String("/SONRS","/FI","FID"))
    Dim INTU_BID As String = ParseQFX(Array As String("/SONRS","INTU.BID"))
    Dim INTU_USERID As String = ParseQFX(Array As String("/SONRS","INTU.USERID"))
    Dim BANKID As String = ParseQFX(Array As String("/BANKACCTFROM","BANKID"))
    Dim ACCTID As String = ParseQFX(Array As String("/BANKACCTFROM","ACCTID"))
    Dim DTSTART As String = ParseQFX(Array As String("DTSTART"))
    Dim DTEND As String = ParseQFX(Array As String("DTEND"))
    Dim BALAMT_L As String = ParseQFX(Array As String("/LEDGERBAL","BALAMT"))
    Dim BALAMT_A As String = ParseQFX(Array As String("/AVAILBAL","BALAMT"))
    Dim DTASOF_L As String = ParseQFX(Array As String("/LEDGERBAL","DTASOF"))
    Dim DTASOF_A As String = ParseQFX(Array As String("/AVAILBAL","DTASOF"))
    Dim sI As Int = 1
    Dim bI, eI, LineCount As Int
    Dim eT As Int
    Do While sI=sI
        Dim QD() As String  = Array As String ("<STMTTRN><TRNTYPE>","<DTPOSTED>","<TRNAMT>","<FITID>","CHECKNUM>","<NAME>","<MEMO>")
        For I = 0 To QD.Length-1
            If I = 0 Then
                eT = qfxData.IndexOf2("</STMTTRN>",sI)
            End If
            bI=qfxData.indexof2(QD(I),sI)
            eI=qfxData.indexof2("<",bI+QD(I).Length+1)
            If (eI > bI ) And (bI > 0) And (bI < eT)Then
                QD(I) = qfxData.SubString2(bI+QD(I).Length,eI)
            Else
                QD(I) = ""
            End If
        Next
        sI=eT +1
        LineCount=LineCount+1
        Log ("SI=" & sI & " ET=" & eT & " T=" & QD(0) & " D=" & QD(1) & " A=" & QD(2) & " F=" & QD(3) & " C=" & QD(4) & " N=" & QD(5) & " M=" & QD(6) )
       
        'This is the part that actually does the update ===========================================
        Dim params As List
        params.Initialize
        params.AddAll(Array(     QD(0), QD(1), QD(2), QD(3), QD(4), QD(5), QD(6)   ))
        If QD(0)="" Then
            Exit
        End If
        B4XTableD.sql1.ExecNonQuery2($"INSERT INTO data VALUES("D", ?, ?, ?, ?, ?, ?, ?)"$,params)
        'This is the part that actually does the update ===========================================
       
    Loop
    B4XTableD.Refresh
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1.
B4X:
 Dim params As List
        params.Initialize
        params.AddAll(Array(     QD(0), QD(1), QD(2), QD(3), QD(4), QD(5), QD(6)   ))
Better:
B4X:
Dim params As List = Array(QD(0), QD(1), QD(2), QD(3), QD(4), QD(5), QD(6))

2. You should have said in the first post that you are modifying the internal db. We cannot guess it.

3. You should call B4XTable.ClearDataView after you modify the database. This will cause the counters to be updated.
 
Upvote 0

Mikelgiles

Active Member
Licensed User
Longtime User
1.
B4X:
 Dim params As List
        params.Initialize
        params.AddAll(Array(     QD(0), QD(1), QD(2), QD(3), QD(4), QD(5), QD(6)   ))
Better:
B4X:
Dim params As List = Array(QD(0), QD(1), QD(2), QD(3), QD(4), QD(5), QD(6))

2. You should have said in the first post that you are modifying the internal db. We cannot guess it.

3. You should call B4XTable.ClearDataView after you modify the database. This will cause the counters to be updated.

Thanks Erel, I have changed the code but won't be able to test until I get a new download to import.
1. Does Dim params As List = Array(.... Initialize internally or is a Initialize not required?
2. Sorry, I just assumed inserting records had to be done to the underlining DB.
2a. What would be the proper way when inserting a record?
2b. What would be the proper way if just updating a record?
2c. Am I correct in assuming that B4XTable.Refresh updates the table based on what is in the DB?
2d. Is there a command that updates the DB from the table or does that have to be done individually?
 
Upvote 0
Top