Commit b3b11514 by Qiang Xue

Finished draft implementation of GridView.

parent ca35bb05
...@@ -169,7 +169,7 @@ abstract class Application extends Module ...@@ -169,7 +169,7 @@ abstract class Application extends Module
public function registerErrorHandlers() public function registerErrorHandlers()
{ {
if (YII_ENABLE_ERROR_HANDLER) { if (YII_ENABLE_ERROR_HANDLER) {
ini_set('display_errors', 0); //ini_set('display_errors', 0);
set_exception_handler(array($this, 'handleException')); set_exception_handler(array($this, 'handleException'));
set_error_handler(array($this, 'handleError'), error_reporting()); set_error_handler(array($this, 'handleError'), error_reporting());
if ($this->memoryReserveSize > 0) { if ($this->memoryReserveSize > 0) {
......
...@@ -230,10 +230,10 @@ return array( ...@@ -230,10 +230,10 @@ return array(
'yii\widgets\ContentDecorator' => YII_PATH . '/widgets/ContentDecorator.php', 'yii\widgets\ContentDecorator' => YII_PATH . '/widgets/ContentDecorator.php',
'yii\widgets\DetailView' => YII_PATH . '/widgets/DetailView.php', 'yii\widgets\DetailView' => YII_PATH . '/widgets/DetailView.php',
'yii\widgets\FragmentCache' => YII_PATH . '/widgets/FragmentCache.php', 'yii\widgets\FragmentCache' => YII_PATH . '/widgets/FragmentCache.php',
'yii\widgets\grid\CheckboxColumn' => YII_PATH . '/widgets/grid/CheckboxColumn.php', 'yii\grid\CheckboxColumn' => YII_PATH . '/grid/CheckboxColumn.php',
'yii\widgets\grid\Column' => YII_PATH . '/widgets/grid/Column.php', 'yii\grid\Column' => YII_PATH . '/grid/Column.php',
'yii\widgets\grid\DataColumn' => YII_PATH . '/widgets/grid/DataColumn.php', 'yii\grid\DataColumn' => YII_PATH . '/grid/DataColumn.php',
'yii\widgets\GridView' => YII_PATH . '/widgets/GridView.php', 'yii\grid\GridView' => YII_PATH . '/grid/GridView.php',
'yii\widgets\InputWidget' => YII_PATH . '/widgets/InputWidget.php', 'yii\widgets\InputWidget' => YII_PATH . '/widgets/InputWidget.php',
'yii\widgets\LinkPager' => YII_PATH . '/widgets/LinkPager.php', 'yii\widgets\LinkPager' => YII_PATH . '/widgets/LinkPager.php',
'yii\widgets\LinkSorter' => YII_PATH . '/widgets/LinkSorter.php', 'yii\widgets\LinkSorter' => YII_PATH . '/widgets/LinkSorter.php',
......
...@@ -5,19 +5,28 @@ ...@@ -5,19 +5,28 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\widgets\grid; namespace yii\grid;
use Closure; use Closure;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* CheckboxColumn displays a column of checkboxes in a grid view.
* Users may click on the checkboxes to select rows of the grid. The selected rows may be
* obtained by calling the following JavaScript code:
*
* ~~~
* var keys = $('#grid').yiiGridView('getSelectedRows');
* // keys is an array consisting of the keys associated with the selected rows
* ~~~
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class CheckboxColumn extends Column class CheckboxColumn extends Column
{ {
public $name; public $name = 'selection';
public $checkboxOptions = array(); public $checkboxOptions = array();
public $multiple = true; public $multiple = true;
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\widgets\grid; namespace yii\grid;
use Closure; use Closure;
use yii\base\Object; use yii\base\Object;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\GridView;
/** /**
* Column is the base class of all [[GridView]] column classes.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\widgets\grid; namespace yii\grid;
use yii\base\InvalidConfigException;
use yii\base\Model; use yii\base\Model;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;
...@@ -20,8 +20,22 @@ use yii\helpers\Inflector; ...@@ -20,8 +20,22 @@ use yii\helpers\Inflector;
*/ */
class DataColumn extends Column class DataColumn extends Column
{ {
/**
* @var string the attribute name associated with this column. When neither [[content]] nor [[value]]
* is specified, the value of the specified attribute will be retrieved from each data model and displayed.
*
* Also, if [[header]] is not specified, the label associated with the attribute will be displayed.
*/
public $attribute; public $attribute;
/**
* @var \Closure an anonymous function that returns the value to be displayed for every data model.
* If this is not set, `$model[$attribute]` will be used to obtain the value.
*/
public $value; public $value;
/**
* @var string in which format should the value of each data model be displayed as (e.g. "text", "html").
* Supported formats are determined by the [[GridView::formatter|formatter]] used by the [[GridView]].
*/
public $format; public $format;
/** /**
* @var boolean whether to allow sorting by this column. If true and [[attribute]] is found in * @var boolean whether to allow sorting by this column. If true and [[attribute]] is found in
...@@ -30,13 +44,13 @@ class DataColumn extends Column ...@@ -30,13 +44,13 @@ class DataColumn extends Column
*/ */
public $enableSorting = true; public $enableSorting = true;
/** /**
* @var string|array|boolean the HTML code representing a filter input (eg a text field, a dropdown list) * @var string|array|boolean the HTML code representing a filter input (e.g. a text field, a dropdown list)
* that is used for this data column. This property is effective only when * that is used for this data column. This property is effective only when [[GridView::filterModel]] is set.
* {@link CGridView::filter} is set. *
* If this property is not set, a text field will be generated as the filter input; * - If this property is not set, a text field will be generated as the filter input;
* If this property is an array, a dropdown list will be generated that uses this property value as * - If this property is an array, a dropdown list will be generated that uses this property value as
* the list options. * the list options.
* If you don't want a filter for this data column, set this value to false. * - If you don't want a filter for this data column, set this value to be false.
*/ */
public $filter; public $filter;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\widgets\grid; namespace yii\grid;
use yii\web\AssetBundle; use yii\web\AssetBundle;
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\widgets\grid; namespace yii\grid;
/** /**
* SerialColumn displays a column of row numbers (1-based). * SerialColumn displays a column of row numbers (1-based).
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment