Structures_DataGrid_DataSource_Array – Array Data Source Driver


This class is a data source driver for a 2D array

Supported operations modes

This driver supports the following operation modes:

Supported operations modes of this driver
Mode Supported?
Multiple field sorting no
Insert, update and delete records no


This driver accepts the following options:

Options for this driver
Option Type Description Default Value
fields array Which data fields to fetch from the datasource. An empty array means: all fields. Form: array(field1, field2, ...) array()
generate_columns bool Generate Structures_DataGrid_Column objects with labels. See the 'labels' option. DEPRECATED: use Structures_DataGrid::generateColumns() instead false
labels array Data field to column label mapping. Only used when 'generate_columns' is true. Form: array(field => label, ...) DEPRECATED: use Structures_DataGrid::generateColumns() instead array()
natsort boolean Whether the array should be sorted naturally (e.g. example1, Example2, test1, Test2) or not (e.g. Example2, Test2, example1, test1; i.e. capital letters will come first). false
primaryKey array Name(s), or numerical index(es) of the field(s) which contain a unique record identifier (only use several fields in case of a multiple-fields primary key) null

General notes

This driver expects an array of the following form:

$data = array(0 => array('col0' => 'val00', 'col1' => 'val01', ...),
              1 => array('col0' => 'val10', 'col1' => 'val11', ...),

The first level of this array contains one entry for each row. For every row entry an array with the data for this row is expected. Such an array contains the field names as the keys. For example, 'val01' is the value of the column with the field name 'col1' in the first row. Row numbers start with 0, not with 1.

DataSource drivers (Previous) Comma Separated Value (CSV) Data Source Driver (Next)
Last updated: Sun, 22 Jan 2017 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:
  • English

User Notes:

Note by:
The 2D array should have only labels for the columns not for the rows.


$datagrid =& new Structures_DataGrid();

$fruits = array (
array ("a"=>"orange", "b"=>"banane", "c"=>"pomme"),
array ("a"=>"citron", "b"=>"mangue", "c"=>"fraise"));

$test = $datagrid->bind($fruits,array(),'Array');