Commit 47dceeb9 by Crisu

added styles for grid view sorting and filters

parent 218da578
......@@ -24,14 +24,20 @@ span.required {
}
.grid-view table.items th a .caret {
display: none;
position: absolute;
right: 5px;
top: 7px;
}
.grid-view table.items th a.asc .caret {
display: block;
}
.grid-view table.items th a.desc .caret {
border-bottom: 4px solid #000;
border-top: none;
display: block;
}
.grid-view table.items tr.selected td {
......@@ -60,13 +66,14 @@ span.required {
font-style: italic;
}
.grid-view .filters .filter-container {
padding: 0 10px 0 0;
}
.grid-view .filters input,
.grid-view .filters select {
border: none;
margin-bottom: 0;
padding: 0;
width: 100%;
box-shadow: none; -o-box-shadow: none; -moz-box-shadow: none; -ms-box-shadow: none; -webkit-box-shadow: none;
}
/*
......
......@@ -393,7 +393,7 @@
}
// Reset filters for IE
.reset-filter() {
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
}
......
<?php
/**
* BootDataColumn class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package bootstrap.widgets
*/
Yii::import('zii.widgets.grid.CDataColumn');
/**
* Bootstrap grid data column
*/
class BootDataColumn extends CDataColumn
{
/**
* Renders the header cell content.
* This method will render a link that can trigger the sorting if the column is sortable.
*/
protected function renderHeaderCellContent()
{
if ($this->grid->enableSorting && $this->sortable && $this->name !== null)
{
$label = isset($this->header) ? $this->header : $this->grid->dataProvider->getSort()->resolveLabel($this->name);
$label .= '<span class="caret"></span>';
echo $this->grid->dataProvider->getSort()->link($this->name, $label);
}
else
{
if ($this->name !== null && $this->header === null)
{
if ($this->grid->dataProvider instanceof CActiveDataProvider)
echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
else
echo CHtml::encode($this->name);
}
else
parent::renderHeaderCellContent();
}
}
/**
* Renders the filter cell.
*/
public function renderFilterCell()
{
echo '<td><div class="filter-container">';
$this->renderFilterCellContent();
echo '</div></td>';
}
}
......@@ -8,6 +8,7 @@
*/
Yii::import('zii.widgets.grid.CGridView');
Yii::import('bootstrap.widgets.BootDataColumn');
/**
* Bootstrap grid view widget.
......@@ -67,4 +68,40 @@ class BootGridView extends CGridView
$this->itemsCssClass .= ' '.implode(' ', $class);
}
/**
* Creates column objects and initializes them.
*/
protected function initColumns()
{
foreach ($this->columns as $i => $column)
{
if (is_array($column) && !isset($column['class']))
$this->columns[$i]['class'] = 'bootstrap.widgets.BootDataColumn';
}
parent::initColumns();
}
/**
* Creates a column based on a shortcut column specification string.
* @param mixed $text the column specification string
* @return \BootDataColumn|\CDataColumn the column instance
* @throws CException if the column format is incorrect
*/
protected function createDataColumn($text)
{
if (!preg_match('/^([\w\.]+)(:(\w*))?(:(.*))?$/', $text, $matches))
throw new CException(Yii::t('zii', 'The column must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.'));
$column = new BootDataColumn($this);
$column->name = $matches[1];
if (isset($matches[3]) && $matches[3] !== '')
$column->type = $matches[3];
if (isset($matches[5]))
$column->header = $matches[5];
return $column;
}
}
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