1

i did this grid in xojo, the problem is that it duplicates me the same rows as before even if I go out and back,

that's the original table with only 3 records: first screenshot

then i made a method to add rows:

Dim i As Integer
Dim v As String
Dim count As Integer
Dim theSQL As String
Dim f As FolderItem
Dim found As Boolean
Dim fin As Integer
Dim vdescrizione1 As String
dim vdatafin as String
dim VnumRec as Integer


//DB MYSQL
Dim db As MySQLCommunityServer
Dim dbfile As folderItem
Dim rec As databaserecord
Dim rs As recordSet

//initialization DB MYSQL
rec=New databaserecord
db=New MySQLCommunityServer

//CONNECTION WEB
db.host ="----"
db.userName = "----"
db.password ="-----"
db.port=----
db.databaseName ="----"

If db.connect Then
Else
MsgBox "MYSQL Portal Data File not available" 
End If


theSQL="Select id,nome,cognome,sesso,residenza,annoNascita FROM CnaPr.Utente"

rs=db.sQLSelect(theSQL)

dim intCycle as Integer=1
dim intMax as Integer = 1000

dim intRow as Integer
dim vfp as Integer
dim r as new Random
dim cValue as Color = rgb( r.InRange( 0, 255 ), r.InRange( 0, 255 ), r.InRange( 0, 255 ) )
dim blnED as Boolean

while not rs.eOF
dim dict as new Dictionary( "K_ID" : rs.field("id").value, _
"K_Nominativo" :  rs.field("nome").value, _
"K_Cognome" :  rs.field("cognome").value, _
"KSesso" :  rs.field("sesso").value,_
"KFinePratica" :  blnED, _
"K_Residenza" :  rs.field("residenza").value,_
"K_Data" :  rs.field("annoNascita").value)

 dim newRow as new GraffitiWebGridRow( dict )
 newRow.Tag = intRow
 AllRows.Append( newRow )
 rs.MoveNext
 Wend

 gwpMain.TotalPages = Ceil(intMax / 20)
 LoadPage( 0 )

the second method:

dim pageMin as Integer = pageIndex * rowsPerPage
//rowsPerPage
dim pageMax as Integer = pageMin + rowsPerPage
dim maxPages as Integer = (AllRows.Ubound +1 ) / rowsPerPage

if pageIndex < 0 or pageIndex > maxPages then Return

GridList.LockUpdate = True
GridList.DeleteAllRows()

for intCycle as Integer = pageMin to Min( pageMax - 1, AllRows.Ubound )
GridList.AddRow( AllRows(intCycle) )
next
GridList.LockUpdate = False
currentPage = pageIndex

when I go back to the previous page and then go back to the table, it doesn't leave me the records I had but on the contrary it duplicates them, second screenshot

  • You don't say what calls the first block of code. But since you're putting things into an AllRows array property that the second block of code uses, it seems likely that your first code is running every time the page is loaded and just adding things to the array. You might try clearing it first with AllRows.RemoveAll. – Paul Lefebvre Mar 17 '21 at 18:35

0 Answers0