Back
checkBoxes
Table Rows and Columns
checkBoxes
Display checkboxes in each row, and menu to act on items checked.
Default:
The following example:

$lens->checkBoxes = 'move^Move Records;del^Hide Records';

Will make a set of checkboxes appear on the grid, one for each row. There will be a menu to select "Move Records" and "Hide Records". Make sure that the keyCol property (defines the primary key) is also set to ensure that the checkboxes return something meaningful.

To process records, check multiple records, then select an item from the menu, say "Move Records", then click on Go. This will cause a POST to occur, with $id being the applet id:

$_POST[$id.'__cbopt'] set to 'move'
$_POST[$id.'__cbstr'] Primary keys of the checked records stored as a string, delimited by the value of $lens->checkBoxesSep, eg. '!#@'.
$_POST[$id.'__cbnotstr']Primary keys of the unchecked records stored as a string, delimited by the value of $lens->checkBoxesSep, eg. '!#@'.

Then you will have to write some PHP code to process this $_POST yourself, eg.

if (isset($_POST[$id.'__cbopt']) && $_POST[$id.'__cbopt'] == 'move') {
  $arr = explode('!#@', $_POST[$id.'__cbstr'];
  foreach($arr as $primkey) {
    # some code to move records based on $primkey ...
  }
}

The checkbox posting code uses javascript to post the data, so will not interfere with any form tags you have embedded inside the grid, or the editMultiple property form tags.

Special Flags

_auto_

The default dropdown menu has a Go button that needs to be pressed before the form results are submitted. Setting this flag will cause selecting from the dropdown menu to submit the results.

$lens->checkBoxes = 'move^Move Records;del^Hide Records;_auto_';


_update_^$colname[^$updateflds]

In the following example:

$lens->checkBoxes = 'move^Move Records;del^Hide Records;_update_^statusfld';

When a user selects 'move', then all checked records will be updated with 'move':

UPDATE $keyTable SET statusfld='move' where (statusfld != 'move' or statusfld) is null and $keyCol=$checkedPrimaryKey


The $updateflds parameter is useful when you need to update additional information. For example:

$lens->checkBoxes = 'move^Move Records;del^Hide Records;_update_^statusfld^modified=sysdate';

Will cause the following sql to be generated:


UPDATE $keyTable SET statusfld='move',modified=sysdate where (statusfld != 'move' or statusfld) is null and $keyCol=$checkedPrimaryKey


_col_^$colname[^$emptyval][^$updateflds]

This ties the checkbox to a database column. Useful for approvals and similar functionality. When the user changes the field, the database is also updated.

If the value of the field satisfies the PHP empty() function [null or 0 or '' or '0' or false], then the checkbox is unchecked, otherwise the checkbox is checked.

In this mode, only the records that are changed (clicked on by the user) are POSTed to the server.

$lens->checkBoxes = '1^Approve Records;_col_^select_field^0';

So records that are checked will be updated with:

UPDATE $keyTable SET select_field=1 WHERE (select_field!=1 or select_field is null) and $keyCol=$checkedPrimaryKey

and records that are unchecked:

UPDATE $keyTable SET select_field=0 WHERE (select_field!=0 or select_field is null) and $keyCol=$uncheckedPrimaryKey

The _update_ flag is ignored in when _col_ is defined.

The $updateflds parameter is useful when you need to update additional information, and is used in the same way as in _update_.

Syntax
$lens->checkBoxes = 'move^Move Records;del^Hide Records';
$lens->keyCol = 'PrimaryKeyField'; ## required

 Basic:Yes  Advanced/Enterprise:Yes  DynamicEdit:Yes   [Version 4.1]