Article

How to bind a bindingsource to a datagridview with batching.

Information

 
Article Number000093738
EnvironmentProduct: OpenEdge
Version: 11.x
OS: Windows
Other: GUI for .NET
Question/Problem Description
If the number of rows to be loaded into a visual object (some sort of grid for form) is small, a probindingsource can be used, as is, to load all of the rows into the visual object at once. If there are thousands of rows to load into a visual object, loading all of the rows into the object at once, could introduce a sizable delay, before the user sees any of the rows displayed in the visual object. To mitigate this delay, batching can be used to allow the probindingsource to load a subset of the rows into the visual object and to display those rows. When the user reaches the end of the rows loaded so far, the visual object can request an additional subset of the rows to be loaded from the probindingsource. This process continues until all of the rows have been so loaded. 
Steps to Reproduce
Clarifying Information
The query is linked to a binding source.
Data must be loaded into a prodataset. The prodataset must contain at least one temp-table.
Data loading is accomplished using the fill() method.
 
Error Message
Defect/Enhancement Number
Cause
Resolution
The attached .zip file contains a project demonstrating the creation of a datagridview, a probindingsource, a prodataset and a temp-table. The sample application uses the sports2000 database as the source of the rows. The Customer table within the sports2000 database is the ultimate source of the data rows. There is nothing special about the sports2000 database or the Customer table. They were chosen for demonstration purposes.

General operation of the sample application:
Run procedure RunForm1.p. RunForm1.p instantiates an object of type example_form.cls. In example_form.cls, the probindingsource is created, the datagridview is instantiated, the probindingsource is associated with the datagridview and the batching is implemented using an event handler for the off-end event.

Highlights of the sample application:
an example_form object is instantiated:
rTemp = NEW example_form ( ) .
A datagridview object is instantiated:
THIS-OBJECT:dataGridView1 = NEW System.Windows.Forms.DataGridView().
a probindingsource is instantiated:
gMyBindingSource = NEW Progress.Data.BindingSource().
The probindingsource is associated with the datagridview:
THIS-OBJECT:dataGridView1:DataSource = gMyBindingSource.
A query is created with a predicate and is associated with the probindingsource:
gMyBindingSource:HANDLE = hQueryHandle.
The probindingsource's batching attribute is enabled:
gMyBindingSource:Batching = TRUE.
The bindingsource's off-end event handler is set up:
 THIS-OBJECT:gMyBindingSource:OffEnd:Subscribe(THIS-OBJECT:handleTheoffendEvent).
The job of the off-end event handler is to call a method that does the following:
     reattach the prodatasource to the prodataset's temp-table.
     reset the prodataset's temp-table's BATCH-SIZE attribute
     Execute the prodataset's fill() method.
     Check for the temp-table's LAST-BATCH attribute being set to TRUE (end of rows available).
     Record the next row from which the next batch will commence.
     Detatch the prodatasource.
     Prepare and open the probidingsource's query.
The off-end event continues to fire until the probindingsource's Batching attribute is set to FALSE. This should be done when the temp-table's LAST-BATCH attribute is set to TRUE.

The attached .zip file contains the entire application. All significant lines of code are commented.
    
Workaround
Notes
References to other Documentation:

GUI for .NET Programming: Binding ABL Data to .NET Controls: ABL and .NET data binding models: .NET data binding:
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvngp/.net-data-binding.html

ABL Reference: Class, Interface, and Enumeration Reference: Progress.Data.BindingSource class:
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/progress.data.bindingsource-class.html

ProDataSets: Advanced Events and Attributes:
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvpds%2Fadvanced-events-and-attributes.html%23

GUI for .NET Programming:
Binding ABL Data to .NET Controls: Managing data updates: Handling user interface events: Using the OffEnd event:
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvngp/using-the-offend-event.html

ProDataSets: Batching Data with ProDataSets:
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvpds/batching-data-with-prodatasets.html

ABL Reference: Class Properties and Methods Reference: Batching property:
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/batching-property.html

Progress article(s):

000022084, How to set the records to batch for a ProDataSet temp-table
000069609, Simple example code demonstrating batching records
000030106, BATCH-SIZE attibute is not passed from the client side to the AppServer
Attachment
Last Modified Date1/10/2019 3:20 PM


Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025