B4J Question SOLVED --ABMTable --Problem in getting the pagination to work

BigBoss123

Member
Licensed User
Longtime User
Here is the screenshot where I have some 143 records but cannot get the pagination to work.

Can anybody help me with this problem.
Thanks



B4J ABM Table:
public Sub BuildPage()
    ' initialize the theme
    BuildTheme
    
    ' initialize this page using our theme
    page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, ABMShared.SessionMaxInactiveIntervalSeconds, theme)
    page.ShowLoader=True
    page.PageHTMLName = "index.html"
    page.PageTitle = ""
    page.PageDescription = ""
    page.PageKeywords = ""
    page.PageSiteMapPriority = ""
    page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_YEARLY
        
    page.ShowConnectedIndicator = True
                
    ' adding a navigation bar
    ABMShared.BuildNavigationBar(page, " {B} Wairarapa Storage (2021) Ltd {/B}","../images/logo.png", "", "", "")
            
    ' create the page grid

    page.AddRowsM(5,True,0,10, "").AddCellsOS(1,0,0,0,12,12,12,"")   
    page.AddRowsM(5,False,0,5,"").AddCellsOSMP(2,0,0,0,6,6,6,10,10,0,0,"")
    page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
        
End Sub



public Sub ConnectPage()           
    '    connecting the navigation bar
    ABMShared.ConnectNavigationBar(page)

    Dim pagination As ABMPagination
    pagination.Initialize(page, "pagination",10, True, True, "")
    pagination.SetTotalNumberOfPages(10)
    page.Cell(1,1).AddComponent(pagination)
    Log("added pagination")

    page.Cell(1,1).AddComponent(ABMShared.BuildLabel(page,"FirstLine", "Customer: Schubert Wines Stocktake", ABM.SIZE_H4, "lbltheme1", 0, "25px"))


    ' create a ABMtable to show records
    Dim tblTrans As ABMTable
    tblTrans.Initialize(page, "tblTrans", True, False, True, "tbltheme")
    ' set the headers
    tblTrans.SetHeaders(Array As String( "Barcode", "Current"))
    tblTrans.SetHeaderThemes (Array As String("bg", "bg"))
    tblTrans.SetColumnVisible(Array As Boolean(True,True))
    tblTrans.IsResponsive = True
    tblTrans.IsBordered = True
    
    tblTrans.SetFooter("Total number of Pallets/Bins:  0" , 12, "bg")
    
    ' refresh the page
    
    page.cellR(2,1).AddComponent(tblTrans)
    
'    page.Cell(3,1).SetFixedHeight(400, True)
'   
'    ' Tell the browser we finished loading
    page.FinishedLoading
'    ' restoring the navigation bar position
    page.RestoreNavigationBarPosition

    Log("now loading pallets")
'
    ' create a SQL cursor
    Dim SQL As SQL = DBM.GetSQL
    
    'Get the records

    Dim numproducts As String
    numproducts = DBM.SQLSelectSingleResult(SQL, "Select Count(barcode) FROM products WHERE custindex = 37")
    
    Dim qry As String = "SELECT * FROM products WHERE custindex = 37 ORDER by barcode"
    
    Dim RSlist As List = DBM.SQLSelect(SQL, qry, Null)

    Dim i As Int
    For i = 0 To RSlist.Size -1
        Dim tblFields As Map = RSlist.Get(i)
        
        Dim rCellValues As List
        Dim rCellThemes As List
        rCellValues.Initialize
        rCellThemes.Initialize
        
        rCellValues.Add(tblFields.Get("barcode"))
        rCellThemes.Add("nocolor")
        rCellValues.Add(tblFields.Get("currentbal"))
        rCellThemes.Add("nocolor")
        tblTrans.AddRow("uid" &i,rCellValues)
        tblTrans.SetRowThemes(rCellThemes)
    Next
    
    
    'page.CellR(3,1).AddComponent(tblTrans)
    Log("added tblTrans")
    
    Log("Number of Pallets: "&numproducts)
    tblTrans.SetFooter("Total number of Pallets/Bins: " & numproducts, 12, "bgc")
'   
    tblTrans.Refresh
'   
'    ' refresh the page
    'page.Refresh
    DBM.CloseSQL(SQL)
    
    Dim pagination  As ABMPagination = page.Component("pagination")
    numproducts = numproducts/10
    page.Refresh
'   
End Sub
 

Attachments

  • TableError.PNG
    TableError.PNG
    44.9 KB · Views: 154

khng

Member
Licensed User
Longtime User
Here is the screenshot where I have some 143 records but cannot get the pagination to work.

Can anybody help me with this problem.
Thanks



B4J ABM Table:
public Sub BuildPage()
    ' initialize the theme
    BuildTheme
   
    ' initialize this page using our theme
    page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, ABMShared.SessionMaxInactiveIntervalSeconds, theme)
    page.ShowLoader=True
    page.PageHTMLName = "index.html"
    page.PageTitle = ""
    page.PageDescription = ""
    page.PageKeywords = ""
    page.PageSiteMapPriority = ""
    page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_YEARLY
       
    page.ShowConnectedIndicator = True
               
    ' adding a navigation bar
    ABMShared.BuildNavigationBar(page, " {B} Wairarapa Storage (2021) Ltd {/B}","../images/logo.png", "", "", "")
           
    ' create the page grid

    page.AddRowsM(5,True,0,10, "").AddCellsOS(1,0,0,0,12,12,12,"")  
    page.AddRowsM(5,False,0,5,"").AddCellsOSMP(2,0,0,0,6,6,6,10,10,0,0,"")
    page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
       
End Sub



public Sub ConnectPage()          
    '    connecting the navigation bar
    ABMShared.ConnectNavigationBar(page)

    Dim pagination As ABMPagination
    pagination.Initialize(page, "pagination",10, True, True, "")
    pagination.SetTotalNumberOfPages(10)
    page.Cell(1,1).AddComponent(pagination)
    Log("added pagination")

    page.Cell(1,1).AddComponent(ABMShared.BuildLabel(page,"FirstLine", "Customer: Schubert Wines Stocktake", ABM.SIZE_H4, "lbltheme1", 0, "25px"))


    ' create a ABMtable to show records
    Dim tblTrans As ABMTable
    tblTrans.Initialize(page, "tblTrans", True, False, True, "tbltheme")
    ' set the headers
    tblTrans.SetHeaders(Array As String( "Barcode", "Current"))
    tblTrans.SetHeaderThemes (Array As String("bg", "bg"))
    tblTrans.SetColumnVisible(Array As Boolean(True,True))
    tblTrans.IsResponsive = True
    tblTrans.IsBordered = True
   
    tblTrans.SetFooter("Total number of Pallets/Bins:  0" , 12, "bg")
   
    ' refresh the page
   
    page.cellR(2,1).AddComponent(tblTrans)
   
'    page.Cell(3,1).SetFixedHeight(400, True)
'  
'    ' Tell the browser we finished loading
    page.FinishedLoading
'    ' restoring the navigation bar position
    page.RestoreNavigationBarPosition

    Log("now loading pallets")
'
    ' create a SQL cursor
    Dim SQL As SQL = DBM.GetSQL
   
    'Get the records

    Dim numproducts As String
    numproducts = DBM.SQLSelectSingleResult(SQL, "Select Count(barcode) FROM products WHERE custindex = 37")
   
    Dim qry As String = "SELECT * FROM products WHERE custindex = 37 ORDER by barcode"
   
    Dim RSlist As List = DBM.SQLSelect(SQL, qry, Null)

    Dim i As Int
    For i = 0 To RSlist.Size -1
        Dim tblFields As Map = RSlist.Get(i)
       
        Dim rCellValues As List
        Dim rCellThemes As List
        rCellValues.Initialize
        rCellThemes.Initialize
       
        rCellValues.Add(tblFields.Get("barcode"))
        rCellThemes.Add("nocolor")
        rCellValues.Add(tblFields.Get("currentbal"))
        rCellThemes.Add("nocolor")
        tblTrans.AddRow("uid" &i,rCellValues)
        tblTrans.SetRowThemes(rCellThemes)
    Next
   
   
    'page.CellR(3,1).AddComponent(tblTrans)
    Log("added tblTrans")
   
    Log("Number of Pallets: "&numproducts)
    tblTrans.SetFooter("Total number of Pallets/Bins: " & numproducts, 12, "bgc")
'  
    tblTrans.Refresh
'  
'    ' refresh the page
    'page.Refresh
    DBM.CloseSQL(SQL)
   
'    Dim pagination  As ABMPagination = page.Component("pagination")
    numproducts = numproducts/10
    page.Refresh
'  
End Sub
try to comment out Dim pagination As ABMPagination = page.Component("pagination") near page.Refresh
 
Upvote 0

BigBoss123

Member
Licensed User
Longtime User
Unfortunately this did not work.
Also when the desktop screen is reduced to a tablet size this is what happens!!

Any ideas would be most grateful.
 

Attachments

  • TableError1.PNG
    TableError1.PNG
    39.4 KB · Views: 150
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Also when the desktop screen is reduced to a tablet size this is what happens
This is because of that line: tblTrans.IsResponsive = True

The Materialize CSS framework does that. Can't say I like their solution either, so most of the time I don't set this. ;)

Alwaysbusy
 
Upvote 0

BigBoss123

Member
Licensed User
Longtime User
Thanks that fixed that problem but I still have the problem that the pages are not working and all records are showing
in a single page.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Thanks that fixed that problem but I still have the problem that the pages are not working and all records are showing
in a single page.
Take a look at the source code of the feedback app what you do different (in the downloaded zip) as it does pagination of a table. You do have to use LIMIT in your queries and grab first e.g. the first 10, then on pressing button 2, 11 to 20, etc.

Alwaysbusy
 
Upvote 0

BigBoss123

Member
Licensed User
Longtime User
Thanks Alain you advice worked great. Sure a little messy, and I not sure when clients log in through the internet what the traffic will be like, but hey the screens now start to look great.
 

Attachments

  • TableCorrect.PNG
    TableCorrect.PNG
    85 KB · Views: 142
Upvote 0
Top