RecordCount property

Official Content
This documentation is valid for:
To obtain or set the number of records of a Grid or Freestyle Grid.

Description

The RecordCount returns the number of records of the Grid that meet the selection conditions. It may return -1 if the program could not determine it (it was not assigned and it could not be calculated automatically).  
 

Value Comment Suggestion
-1 It could not be determined. Typically, the Grid does not have a base table or the loading conditions are evaluated client side. Since the program could not calculate it automatically, you should set its value in the Refresh event.
>= 0 Number of records of the Grid base table  

Run-time/Design-time

This property applies only at run-time.

Samples

1) Grid with base table (GridCount could be calculated automatically)

Event Refresh
msg(str(Grid1.RecordCount))
msg(str(grid1.PageCount))
EndEvent

2) Grid is based on SDT (GridCount could be calculated automatically)

Event Refresh
   &Clients = ClientsGet()
   msg(str(grid1.RecordCount))    
   msg(str(grid1.PageCount))
EndEvent
Event Load
    for &Client in &Clients
        &Clientid = &Client.ClientId
        &ClientName = &Client.ClientName
        load
    endfor
EndEvent

3) Grid is loaded from external sources (RecordCount could not be calculated automatically)
This case requires that RecordCount is assigned in the Refresh Event. If not, the Pagecount could not be determined when the Web Panel loads.

Event Refresh
   grid1.Rows = 5
   grid1.RecordCount = 12
   msg(str(grid1.PageCount))
   msg(str(grid1.RecordCount))
Event Load
   for &i = 1 to 12
      &ClientId = GetClientId(&i)
      &ClientName = GetClientName(&i)
      load
   endfor
EndEvent

Scope

Objects: Web Panel
Platforms: Web(.Net, Java), Web(.Net Core)
Controls: FreeStyle Grid, Grid

See Also

PageCount Property
Grid paging on the Web
Paging in apps