B4J Question [ABMaterial] ABMReport Creation After ConnectPage

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
I am trying to use the ABMReport.
The example provided here
creates and shows the report in the ConnectPage section with this code:
B4X:
Dim myReport As ReportInvoice
myReport.Initialize(page, "myreport")
page.Cell(4,1).AddComponent(myReport.Report)
So, the report is created, populated with data and shown upon page creation. All data are created in the Report_Build sub This works fine.
I also modified the code to use queries to populate the report.

However, usually a report needs to be generated after a certain event (e.g. user selects the invoice number for which a report is needed).

How can I generate the report outside ConnectPage?
 
Last edited:

John Naylor

Active Member
Licensed User
Longtime User
Remove those three lines from your ConnectPage and make a sub which looks like this....

B4X:
Sub GenerateReport
  
    Dim myReport As ReportInvoice
    myReport.Initialize(page, "myReport")
    page.Cell(4,1).AddComponent(myReport.Report)
  
    page.Refresh

End Sub

Add the following to your ConnectPage to add a button that you can use to actually display the report (Obviously in actual use you would do whatever you want to do before calling the above sub but this will demonstrate how to do what you want)

B4X:
    Dim GenRep As ABMButton
    GenRep.InitializeRaised(page,"DisplayReport","","","Go","")
    page.Cell(1,1).AddComponent(GenRep)

and finally a handler for when the button is clicked

B4X:
Sub    DisplayReport_Clicked (target As String)
  
    GenerateReport
  
End Sub

So now the program starts and you see the ABMPage but without a report. You can do whatever extra processing you require then call the GenerateReport sub which will display the control when you want it. - In your case you would have a text box for the user to enter an invoice number then generate the report.
 
Last edited:
Upvote 0

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
I think i tried this solution with no success but i suspect i might have skipped the page.refresh which you have at the end of the GenerateReport sub.
I will implement your suggestion on Monday and revert back with the results.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Yes, the page.refresh is something like: 'I've defined all the changes on the server side, now push them to the browser'.

To speed things up, you can als use the more detailed .refresh methods, like cell.refresh or row.refresh if you have made only changes in a certain cell or row. Page.Refresh will have to go over everything defined on the page to check if they are dirty or not and need to be pushed to the browser. But in most cases page.refresh is fast enough.
 
Upvote 0
Top