GirdView, limited lines

Post

Posted
Rating:
#1 (In Topic #2026)
Trainee
Zyfriala is in the usergroup ‘Trainee’
Hello,

i open this new post because i have a problem

with a limited view in my Gridview.

I have a table of 226 lignes i can only see 113 lines…

I have another one of 742 lines and i can only see 371 lines.

It seems i can only see HALF of the table.

It seems to me that i already (many years ago, i just came back to Gambas)

encounter that problem.

What do you think ?
Online now: No Back to the top

Post

Posted
Rating:
#2
Trainee
Zyfriala is in the usergroup ‘Trainee’
I forgot to mention
- that i use PostgreSQL as Database…
- that i also use PostgreSQL with Lazarus for the same tables and it works perfectly fine.
 
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

Zyfriala said

What do you think ?
Some example code maybe to show how you populate the GridView?

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#4
Trainee
Zyfriala is in the usergroup ‘Trainee’
here we go…

'================================================================================
'============================ AFFICHE LA TABLE 'JOURNAL' ==========================
'================================================================================
Public Sub su_TableJournalAffiche()

  '=== Pour la boucle
  Dim l As Integer

  '=== RAZ GRIDVIEW
  Grid_Dev.Clear()

  su_LignesCount("journal") '→ gives nLignes_h
  'Message.Info("Table JOURNAL : " & nLignes_h)

  su_GridShape("journal", 12, 10, nLignes_h)
  su_LabelsEtColonnes("journal")

  QueryPG_h = "Select lignes, jour_s, annee, mois, jour, cat, cat_sub, lien, titre, note1, note2 From sch_dev.t_dev_journal ORDER BY lignes "

  '=== RECORDSET / EXECUTION DU RESULT
  ResultConsult_h = $ConVisu.Exec(QueryPG_h)

  '=== On avance au premier enregistrement
  ResultConsult_h.MoveFirst

   '=== Boucle
   For l = 0 To nLignes_h - 1

  '=== VARIABLES
  'lignes,jour_s,annee,mois,jour,cat,cat_sub,lien,titre,note1,note2
  $dev1 = ResultConsult_h!lignes
  $dev2 = ResultConsult_h!jour_s
  $dev3 = ResultConsult_h!annee
  $dev4 = ResultConsult_h!mois
  $dev5 = ResultConsult_h!jour
  $dev6 = ResultConsult_h!cat
  $dev7 = ResultConsult_h!cat_sub
  $dev8 = ResultConsult_h!lien
  $dev9 = ResultConsult_h!titre
  $dev10 = ResultConsult_h!note1
  $dev11 = ResultConsult_h!note2

  '=== APPELLE LA FONCTION GridView1_Data
  fo_GridView1_Ecrit(l, 0, $dev1)
  fo_GridView1_Ecrit(l, 1, $dev2)
  fo_GridView1_Ecrit(l, 2, $dev3)
  fo_GridView1_Ecrit(l, 3, $dev4)
  fo_GridView1_Ecrit(l, 4, $dev5)
  fo_GridView1_Ecrit(l, 5, $dev6)
  fo_GridView1_Ecrit(l, 6, $dev7)
  fo_GridView1_Ecrit(l, 7, $dev8)
  fo_GridView1_Ecrit(l, 8, $dev9)
  fo_GridView1_Ecrit(l, 9, $dev10)
  fo_GridView1_Ecrit(l, 10, $dev11)

 l = l + 1

  ResultConsult_h.MoveNext

  Next

End

'==================================================================================
'===================== MAJ DES DONNEES DE LA GRIDVIEW =============================
'==================================================================================

Public Sub fo_GridView1_Ecrit(Row As Integer, Column As Integer, $data As Variant)

Grid_Dev[Row, Column].Text = $data

End
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Gianluigi is in the usergroup ‘GambOS Contributor’
On the Farm there is an example of mine: DBSpeedyTest which explains how to use GridView_Data
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
Quincunxian is in the usergroup ‘Blogger’
Hi - I would include the line

 '=== RECORDSET / EXECUTION DU RESULT
  ResultConsult_h = $ConVisu.Exec(QueryPG_h)

Code

Message(str(ResultConsult_h.Count))

and compare this to your nLignes_h variable. They should be the same number.
I can't see how you are getting this count so assume that it is a query doing something like (?)

Code

SELECT COUNT(journal) AS JournalCount FROM  sch_dev.t_dev_journal


I've never used Postgres but assume that the Gambas code below 'should' work ok doing this:

Code

ResultConsult_h = $ConVisu.Exec(QueryPG_h)

If Not IsNull(ResultConsult_h) and ResultConsult_h.Available then

For Each ResultConsult_h

(Code to load grid View rows)


Next







 

Cheers - Quin.
I code therefore I am
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

Zyfriala said

here we go…
Like GianLuigi wrote, you should checkout the GridView_Data event.

I'll try to come up with some example code to demonstrate how it works.
Going to bed now, it's past 3 AM here
 :thumbs:

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

Code (gambas)

  1. 'Gambas class file
  2.  
  3. ' gvwResult = GridView
  4. 'A fictional demo where each record holds;
  5. ' Id (a database auto increment unique id)
  6. ' Name (a databas textbased field holding names)
  7. ' DateBirth (a database date field holding birth date)
  8.  
  9. '$hConn is a fictional connection
  10.  
  11.  
  12. Private $rResult As Result
  13.  
  14. Private $sFieldName As String[]
  15.  
  16.  
  17. Public Sub Form_Open()
  18.  
  19.   Dim sQuery As String
  20.  
  21.   sQuery ="SELECT Id, Name, DateBirth FROM Persons ORDER BY Id"
  22.   $rResult = $hConn.Exec(sQuery)
  23.  
  24.   ReadData
  25.  
  26.  
  27. Public Sub gvwResult_Data(Row As Integer, Column As Integer)
  28.  
  29.   Dim iHelp As Variant
  30.  
  31.   $rResult.MoveTo(Row)
  32.   Select Column
  33.     Case 2
  34.        iHelp = $rResult[$sFieldName[Column]]
  35.        gvwResult.Data.Text = Format(iHelp, "dd/mm/yyyy")
  36.     Case Else
  37.        gvwResult.Data.Text = Str($rResult[$sFieldName[Column]])
  38.  
  39.  
  40. Private Sub ReadData()
  41.  
  42.   Dim hField As ResultField
  43.   Dim iX As Integer
  44.  
  45.  
  46.   '--This sets the number of records--
  47.   gvwResult.Rows.Count = $rResult.Count
  48.  
  49.   '--This sets the number of fields (columns)--
  50.   gvwResult.Columns.Count = $rResult.Fields.Count
  51.  
  52.   '--To store the column name--
  53.   $sFieldName = New String[gvwResult.Columns.Count]
  54.  
  55.   For iX = 0 To 3
  56.     gvwResult.Columns[iX].Alignment = 3
  57.   Next
  58.  
  59.   '--Get the fieldnames--
  60.   iX = 0
  61.   For Each hField In $rResult.Fields
  62.     With hField
  63.       gvwResult.Columns[iX].Text = .Name
  64.       $sFieldName [iX]= .Name
  65.     End With
  66.     Inc iX
  67.   Next
  68.  
  69.   '--set width of the columns--
  70.   gvwResult.Rows.Height = 32
  71.   gvwResult.Columns[0].Width = 60           'Id
  72.   gvwResult.Columns[1].Width = 120          'Name
  73.   gvwResult.Columns[2].Width = 95           'BirthDate
  74.  
  75.     Dec Application.Busy
  76.  
  77.  


Seems, I had to quickly create a simple fictional example.
Hope you understand how GridView works and how to populate it correctly.



 

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#9
Trainee
Zyfriala is in the usergroup ‘Trainee’
Thank you for your help,

something was wrong in the loop and i didn't get all the results,

then i modify it

- i suppressed 'ResultConsult_h.MoveFirst

and just modify my loop like that
  
For l = 0 To nLignes_h - 1
       
   ResultConsult_h.MoveTo(l)   

   fo_GridView1_Write(l, 0, ResultConsult_h[0]) '—Writing the datas
   …
   …

Next

works very fine

thank you both for your help and your ideas,
thanks gbWilly for your code
 :thumbs:

 


Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Gianluigi is in the usergroup ‘GambOS Contributor’
Hi Zyfriala

Since I believe that using the gb.db2 DB class greatly facilitates database use under Gambas, I think I should insist.
I proposed my Farm example, but many believe that since the demonstration uses SQLite, it's not suitable for serious databases like PostgreSQL.
I also posted here: Problems with Buscar with Gambas in SQLite3 - Gambas ONE
an example I used to report a bug that works with all three of the most popular databases under GNU/Linux.
I'm adding here a reduction of the Farm example for Postgres.
I hope I've closed the loop.
It should also work on MySQL/MariaDB.

 :goodbye:

Attachment

SpeedTestPostgres-0.0.1.tar.gz

Online now: No Back to the top
1 guest and 0 members have just viewed this.