Android Question SD_FlexGrid Error

DarkoT

Active Member
Licensed User
Hello, I need some help. I'm developing an application for Android tablets, and I'm using SD_FlexGrid. The system is working, but I occasionally get an error: "Refresh: java.lang.IndexOutOfBoundsException: Index: 20, Size: 0" when I try to load new data into the Grid (I clear the existing grid and want to fill it with new data). What could be the cause of this? Please help; the code for refreshing the grid is here:

Example:
            ' clear existing selection
            tblNalogiNovi.ClearSelection
            ' clear all existing rows
            tblNalogiNovi.ClearRows
            Query = $"select wo.WoID as wo,
                             jo.JobID as job,
                             jo.Title as title,
                             jo.StatusName as statusname,
                             jo.CustomerName as customer,
                             wo.Lenght as dolzina,
                             wo.Width as sirina,
                             wo.ProductName as productname,
                             wo.MaterialName as materialname
                      from DiLiteWorkOrders wo inner join DiLiteJobs jo on jo.JobID = wo.JobID
                      where not exists(select * from DiLiteTransactions ac where ac.WoID = wo.WoId) and
                                  (exists(select * from DiLiteTasks tk where tk.WorkOrderID = wo.WoId and (lower(tk.Operation) = lower('${IzbranaOperacija}') or lower('${IzbranaOperacija}') = 'vse operacije')))
                      order by wo desc"$
            Dim rs As ResultSet = comDb.SqlLite.ExecQuery(Query)
            
            ' while records existing
            Do While rs.NextRow
                Dim Kvadratura As String = rs.GetString("dolzina") & "x" & rs.GetString("sirina")
                tblNalogiNovi.AddRow(Array As Object(rs.GetInt("job"), rs.GetInt("wo"), rs.GetString("title"), rs.GetString("statusname"), rs.GetString("customer"), rs.GetString("dolzina"), rs.getstring("sirina"), Kvadratura, rs.GetString("productname"), rs.GetString("materialname")), True)
            Loop
            If rs.RowCount <> 0 Then tblNalogiNovi.Invalidate
            rs.Close
        
            ' color odd lines
            Dim Num As Int = 1
            For x = 0 To tblNalogiNovi.RowCount - 1
                If Num Mod 2 == 0 Then
                    tblNalogiNovi.SetRowCustomize(x, xui.Color_Black, B4XPages.MainPage.ColorLG, xui.CreateDefaultFont(15))
                End If
                Num = Num + 1
            Next

System works correctly, I received just in log following msg: Refresh: java.lang.IndexOutOfBoundsException: Index: 20, Size: 0

What can be wrong? Or should I just ignore this message?

Thank you...
Darko
 
Solution
That's a warning. It means that while he was updating the grid the data was emptied and he could not continue.
I solve the problem... I set Refresh to False and set to filling data without invalidation... And the system works correctly, without any warnings/errors...

Thank you @Star-Dust for your help...

Star-Dust

Expert
Licensed User
Longtime User
Have you updated the library to the latest version?
When does this error appear? It seems like it wants to access the data when you have emptied the grid buffer.

Row coloring works if the entire grid has been created. Is it possible that it is so long that by the time you color the alternate rows you have not yet completed the creation of the Grid?
Try coloring the grid lines when you insert or put a Sleep before coloring the lines
 
Upvote 0

DarkoT

Active Member
Licensed User
Hi,
YES, I have latest version of library... Error appears AFTER I change the data in grid (structure of the grid is still the same). By default (when user open the page first time) I shows all records from some table (f.e. all workorders); when user select some filter (f.e. all open workorders) I clear the table and fill again - but only few records (only records which have status as "open"). The error appears after I clear and fill records again in same structure...
 
Upvote 0

DarkoT

Active Member
Licensed User
And - just for info - the problem is not related with coloring; I turned off coloring and the problem is same... If you want - I can give you code for testing...
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Okay, let's send the source privately. Describe to me step by step the operations to perform to generate the error
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
That's a warning. It means that while he was updating the grid the data was emptied and he could not continue.
 
Upvote 1

DarkoT

Active Member
Licensed User
That's a warning. It means that while he was updating the grid the data was emptied and he could not continue.
I solve the problem... I set Refresh to False and set to filling data without invalidation... And the system works correctly, without any warnings/errors...

Thank you @Star-Dust for your help...
 
Upvote 0
Solution
Cookies are required to use this site. You must accept them to continue using the site. Learn more…