skip to main content

Controls Reference : GRID : Properties : Data-Columns

Data-Columns
The data in a row of the Grid control can be set or retrieved using either a single alphanumeric or a group variable. This property describes the starting position of the information in that variable for each column, starting at 1. The ending position cannot be directly set, it is the character before the first character of the next column.
For example, suppose we have a three-column grid, with the following headers: First Name, Last Name, Address. The buffer necessary to add data to this grid should be structured in a way similar to this:
01  Grid-Data.
    03 First_Name pic x(20).
    03 Last_Name  pic x(30).
    03 Address    pic x(50).
The DATA-COLUMNS property should be set as follows:
DATA-COLUMNS = (1, 21, 51)
Instead of hard-coded values, it is possible to use the RECORD-POSITION syntax:
DATA-COLUMNS = (RECORD-POSITION OF First_Name, 
                RECORD-POSITION OF Last_Name, 
                RECORD-POSITION OF Address)
This syntax avoids problems due to the modification of the item size in the buffer.
When using standard alphanumeric items, the offset of data columns is calculated in bytes, not in digits, so you should pay attention if you’re using a variable length encoding (e.g. UTF-8) to store data in the grid record buffer.
When using national items, you can’t take advantage of the RECORD-POSITION syntax. You need to use values calculated on the items length in digits, For example, for the following group item:
01  Grid-Data USAGE-GROUP NATIONAL.
    03 First_Name pic N(20).
    03 Last_Name  pic N(30).
    03 Address    pic N(50).
the correct DATA-COLUMNS setting is:
DATA-COLUMNS = (1, 21, 51)
and not (1, 41, 101) as RECORD-POSITION would return.
 
Example - Set data columns by reading values from a Occurs
procedure division.
modify screen-1-gr-1, data-columns = -1 | resets the list of values
perform varying columnidx from 1 by 1 until columnidx > columncount
   modify screen-1-gr-1, data-columns = w-data-col(columnidx) 

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left