PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Overview
  • Initializing a memory Table control
  • Adding rows into a memory Table control
  • Managing calculated columns
  • Modifying a row or a column
  • Forcing the input
  • Adding or deleting a column
  • Operations on the rows and cells
  • Deleting a row
  • Retrieving the row content or the cell content
  • Value of a cell in the current row
  • Value of a cell in a specific row
  • Content of current row
  • Content of specific row
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
The main concepts for programming the memory Table controls are as follows.
Several WLanguage functions allow you to manage this type of control by programming. Do not hesitate to see the documentation about these functions.
Initializing a memory Table control
The creation of a row in a Table control is not automatically performed. It must be explicitly requested via a call to:
Note: if the option "Cascading input (Addition)" is not selected:
  • A Table control contains no row when it is created: TABLE_MyTable..Count=0.
    In this case, no input is allowed and ..Empty is set to True.
  • To automatically insert a row if the Table control is empty, the following command lines must be used in the event "Initializing" of the Table control:
    IF TABLE_MyTable..Empty = True THEN TableAdd(TABLE_MyTable)
Adding rows into a memory Table control
Adding rows into a memory Table control is performed:
WEBDEV - Server codePHP If a new row was added into the Table control by TableAdd, TableInsert, TableAddLine or TableInsertLine, ..NewLine is set to True (otherwise, it is set to False).
Managing calculated columns
The calculation formula of a calculated column must be described in the event "Displaying a table row" of a Table control. For example:
// COL_PBT: calculated column
// COL_UPBT and COL_QTY: columns linked to memory zones
COL_PBT = COL_UPBT * COL_QTY
Modifying a row or a column
The content of a Table control's rows or columns can be modified:
  • by the user, by performing an input in the columns. The modifications are automatically stored in the Table control with no additional programming. ..Modified is set to True.
  • by programming:
    • with TableModify to modify the content of the current row or the content of a given row.
      For example:
      TableModify(TABLE_CUSTOMER, "MOORE" + TAB + "Vince" + TAB + "Miami")

      Note: you can also use the name of the Table control directly:
      // Modify the current row
      TABLE_CUSTOMER = "MOORE" + TAB +"Vince" + TAB + "Miami"
      // Modify row 3
      TableModify(TABLE_DAY, "Wednesday" + TAB + "Off", 3)
    • by specifying the column name (like for an edit control) to modify the column content. To modify a column of a specific row, the row number must be specified (subscript).
      For example:
      COL_NAME[Subscript] = EDT_CustomerName

      To modify a column of the current row, there is no need to specify the subscript. For example:
      COL_NAME = EDT_CustomerName

      ..Modified is set to False (it is set to True when an input is performed in the Table control).
Windows

Forcing the input

ReturnToCapture can be used to force the input in a column of the current row.
For example:
// Entry process in the COL_QTY column
// COL_QTY cannot be entered,
// if COL_PRODUCT is not entered
IF NoSpace(COL_PRODUCT) = "" THEN
Error("The Product column must be entered first")
ReturnToCapture(COL_PRODUCT)
END
 
WEBDEV - Server codeWindows

Adding or deleting a column

It is possible to:
Operations on the rows and cells

Deleting a row

The deletion of a row must be explicitly requested by TableDelete. The following syntax is used:
TableDelete(<Table control>[, <Subscript>])
If the subscript is specified, TableDelete deletes the row corresponding to the subscript. Otherwise, the current row is deleted. For example:
TableDelete(TABLE_CUSTOMER)

The deletion of a Table control row also deletes all the values of the columns for this row.
A row can be selected with TableSelectPlus.
The following syntax is used:
TableSelectPlus(<Table control>[, <Subscript>])

Retrieving the row content or the cell content

The content of a memory Table control can be retrieved:
  • for the entire row.
  • cell by cell.

Value of a cell in the current row

To retrieve the value of a column (or cell) for the current row, the syntax is the same as for a simple edit control.
<Value> = <Column name>
Example:
// COL_QTY is a column of the Table control
IF COL_QTY < 10 THEN
Info("Insufficient quantity")
END

Value of a cell in a specific row

To retrieve the value of a column not found on the current row, the row subscript must be specified.
<Value> = <Column name>[<Subscript>]
For example:
// Add the total price before tax (PBT) for all the order lines
TotalPrice = 0
FOR Subscript = 1 _TO_ TABLE_ORDERS..Occurrence
        TotalPrice = TotalPrice + COL_PBT[Subscript]
END

Content of current row

To retrieve the content of the current row, use the following syntax:
<Value> = <Table control>

Content of specific row

To retrieve the content of the row whose subscript is <Subscript>, use the following syntax:
<Value> = <Table control>[<Subscript>]
Note: The subscript of the current row is returned by TableSelect.
For example:
// Retrieve row #10 in the TABLE_CUSTOMER control
CurrentRow = TABLE_CUSTOMER[10]

// Name of selected customer
CustomerName = COL_NAME[TableSelect(TABLE_CUSTOMER)]

// Retrieve the current row in the TABLE_CUSTOMER control
CurrentRow = TABLE_CUSTOMER
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment