Object Mapping ============== Grids are always associated with a single model (although by way of a query they may join other models and select virtual columns). Currently there exists an annotation and array (hence YAML) driver for defining grids. Using the grid factory builder you can easily add metadata drivers: .. note:: In this section, as in the reset of the documentation, will will use annotation mapping in examples. Annotations are good for rapid development and keeping information about objects close to the objects. Instantiation ------------- Array driver: .. code-block:: php addArrayDriver([ // mapping ]) ->createGridFactory(); Annotation driver: .. code-block:: php addAnnotationDriver() ->createGridFactory(); Annotation Example ------------------ The following is a simple grid: .. code-block:: php addArrayDriver([ 'grids' => [ 'main' => [ 'columns' => [ 'active' => [ 'type' => 'boolean', ], 'email' => [ 'type' => 'text', ], 'name' => [ 'type' => 'text', ], ], 'filters' => [ 'active' => [ 'type' => 'boolean', ], 'email' => [ 'type' => 'string', ], 'name' => [ 'type' => 'string', ], ], ] ] ])->createGridFactory(); and a more complicated one with a query: .. code-block:: php addArrayDriver([ 'queries' => [ 'details' => [ 'selects' => [ 'a.id' => 'id', 'a.active' => 'active', 'a.name' => 'name', 'a.email' => 'email', 'p.title' => 'productTitle', ], 'joins' => [ [ 'join' => 'a.product', 'alias' => 'p' ], ], ], ], 'grids' => [ 'main' => [ 'query' => 'details', 'columns' => [ 'active' => [ 'type' => 'boolean', ], 'email' => [ 'type' => 'text', 'options' => [ 'sort_field' => 'a.email', ], ], 'name' => [ 'type' => 'text', 'options' => [ 'sort_field' => 'a.name', ], ], ], 'filters' => [ 'active' => [ 'type' => 'boolean', 'options' => [ 'comparators' => [ 'contains' ], ], ], 'email' => [ 'type' => 'string', 'options' => [ 'label' => 'Member active', ], ], 'name' => [ 'type' => 'string', 'options' => [ 'comparators' => [ 'contains' ], ], ], ], ] ] ])->createGridFactory();