Skip to content

Commit

Permalink
added table-responsive in bootstrapTable/layout, for big tables on mo…
Browse files Browse the repository at this point in the history
…bile views
  • Loading branch information
kokspflanze committed Nov 1, 2015
1 parent 2219296 commit 5c08509
Showing 1 changed file with 116 additions and 114 deletions.
230 changes: 116 additions & 114 deletions view/zfc-datagrid/renderer/bootstrapTable/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -48,137 +48,139 @@ if($this->rowClickAction !== null){

<?php echo $this->partial($this->templateToolbar);?>

<table class="<?php echo implode(' ', $classes); ?>">
<thead>
<tr style="background-color: #EEE">
<?php
if($hasMassActions === true){
echo '<th><input type="checkbox" onclick="' . $this->gridId . '_toggleCheckboxes(this);" /></th>';
}

foreach($this->columns as $col){
/* @var $col \ZfcDatagrid\Column\AbstractColumn */
$classes = array();
$styles = array();

$id = $col->getUniqueId();

$label = '';
if($col->getLabel() != ''){
$label = $this->translate($col->getLabel());
}

$width = $col->getWidth();
if($width != ''){
$styles[] = 'width: '.$this->escapehtmlattr($width).'%';
}


if($col->isHidden() === true){
$classes[] = 'hidden';
}
if($col->getType() instanceof Type\Number){
$styles[] = 'text-align: right';
}
?>
<th id="<?php echo $this->escapehtmlattr($id); ?>" class="<?php echo implode(',', $classes); ?>" style="<?php echo implode(';', $styles); ?>">

<?php if($col->isUserSortEnabled() === true):
if($col->isSortActive() === true && $col->getSortActiveDirection() === 'ASC'){
$direction = 'DESC';
} else{
$direction = 'ASC';
}
?>
<a href="<?php echo
$this->url(null,
array(),
array(
'query' => array_merge($this->activeParameters, array(
$this->parameterNames['sortColumns'] => $col->getUniqueId(),
$this->parameterNames['sortDirections'] => $direction,
)
)
),
true
);?>
" onclick="<?php echo sprintf($orderOnclick, $col->getUniqueId(), $direction); ?>">
<?php echo $this->escapeHtml($label); ?>
</a>
<?php else: ?>
<?php echo $this->escapeHtml($label); ?>
<?php endif; ?>

<?php
if($col->isSortActive() === true){
if($col->getSortActiveDirection() === 'ASC'):?>
<i class="icon-chevron-down glyphicon glyphicon-chevron-down"></i>
<?php else: ?>
<i class="icon-chevron-up glyphicon glyphicon-chevron-up"></i>
<?php endif;
}
?>
</th>
<?php
}
?>
</tr>

<!-- User filters -->
<?php if($this->isUserFilterEnabled === true):?>
<div class="table-responsive">
<table class="<?php echo implode(' ', $classes); ?>">
<thead>
<tr style="background-color: #EEE">
<?php
if($hasMassActions === true){
echo '<td></td>';
echo '<th><input type="checkbox" onclick="' . $this->gridId . '_toggleCheckboxes(this);" /></th>';
}

foreach($this->columns as $col){
/* @var $col \ZfcDatagrid\Column\AbstractColumn */

$classes = array();
$styles = array();

$id = $col->getUniqueId();

$label = '';
if($col->getLabel() != ''){
$label = $this->translate($col->getLabel());
}

$width = $col->getWidth();
if($width != ''){
$styles[] = 'width: '.$this->escapehtmlattr($width).'%';
}


if($col->isHidden() === true){
$classes[] = 'hidden';
}

$htmlFilter = '';
if ($col->isUserFilterEnabled() === true) {

if ($col->hasFilterSelectOptions() === true) {
$htmlFilter = '<select name="toolbarFilters[' . $col->getUniqueId() . ']" style="width: 80%" onchange="this.form.submit()" class="form-control" >';
foreach ($col->getFilterSelectOptions() as $value => $option) {
if ($col->getFilterActiveValue() === $value) {
$htmlFilter .= '<option value="' . $value . '" selected="selected">' . $option . '</option>';
} else if (($col->getFilterActiveValue() === '') && ($value === '')){
$htmlFilter .= '<option value="' . $value . '" selected="selected">' . $option . '</option>';
} else {
$htmlFilter .= '<option value="' . $value . '">' . $option . '</option>';
}
if($col->getType() instanceof Type\Number){
$styles[] = 'text-align: right';
}
?>
<th id="<?php echo $this->escapehtmlattr($id); ?>" class="<?php echo implode(',', $classes); ?>" style="<?php echo implode(';', $styles); ?>">

<?php if($col->isUserSortEnabled() === true):
if($col->isSortActive() === true && $col->getSortActiveDirection() === 'ASC'){
$direction = 'DESC';
} else{
$direction = 'ASC';
}
$htmlFilter .= '</select>';
?>
<a href="<?php echo
$this->url(null,
array(),
array(
'query' => array_merge($this->activeParameters, array(
$this->parameterNames['sortColumns'] => $col->getUniqueId(),
$this->parameterNames['sortDirections'] => $direction,
)
)
),
true
);?>
" onclick="<?php echo sprintf($orderOnclick, $col->getUniqueId(), $direction); ?>">
<?php echo $this->escapeHtml($label); ?>
</a>
<?php else: ?>
<?php echo $this->escapeHtml($label); ?>
<?php endif; ?>

} else if ($col->getType() instanceof \ZfcDatagrid\Column\Type\DateTime){
$htmlFilter = '<input type="text" name="toolbarFilters[' . $col->getUniqueId() . ']" style="width: 80%" value="' . $col->getFilterActiveValue() . '" class="form-control daterange" />';
} else {
$htmlFilter = '<input type="text" name="toolbarFilters[' . $col->getUniqueId() . ']" style="width: 80%" value="' . $col->getFilterActiveValue() . '" class="form-control" />';
<?php
if($col->isSortActive() === true){
if($col->getSortActiveDirection() === 'ASC'):?>
<i class="icon-chevron-down glyphicon glyphicon-chevron-down"></i>
<?php else: ?>
<i class="icon-chevron-up glyphicon glyphicon-chevron-up"></i>
<?php endif;
}
}
?>
<td class="<?php echo implode(',', $classes); ?>">
<?php echo $htmlFilter; ?>
</td>
?>
</th>
<?php
}
?>
</tr>
<?php endif; ?>
</thead><!-- END table header -->

<!-- Start table BODY -->
<tbody>
<?php foreach($this->data as $row): ?>
<?php echo $this->bootstrapTableRow($row, $this->columns, $this->rowClickAction, $this->rowStyles, $hasMassActions); ?>
<?php endforeach; ?>
</tbody>
</table>

<!-- User filters -->
<?php if($this->isUserFilterEnabled === true):?>
<tr style="background-color: #EEE">
<?php
if($hasMassActions === true){
echo '<td></td>';
}
foreach($this->columns as $col){
/* @var $col \ZfcDatagrid\Column\AbstractColumn */

$classes = array();
if($col->isHidden() === true){
$classes[] = 'hidden';
}

$htmlFilter = '';
if ($col->isUserFilterEnabled() === true) {

if ($col->hasFilterSelectOptions() === true) {
$htmlFilter = '<select name="toolbarFilters[' . $col->getUniqueId() . ']" style="width: 80%" onchange="this.form.submit()" class="form-control" >';
foreach ($col->getFilterSelectOptions() as $value => $option) {
if ($col->getFilterActiveValue() === $value) {
$htmlFilter .= '<option value="' . $value . '" selected="selected">' . $option . '</option>';
} else if (($col->getFilterActiveValue() === '') && ($value === '')){
$htmlFilter .= '<option value="' . $value . '" selected="selected">' . $option . '</option>';
} else {
$htmlFilter .= '<option value="' . $value . '">' . $option . '</option>';
}
}
$htmlFilter .= '</select>';

} else if ($col->getType() instanceof \ZfcDatagrid\Column\Type\DateTime){
$htmlFilter = '<input type="text" name="toolbarFilters[' . $col->getUniqueId() . ']" style="width: 80%" value="' . $col->getFilterActiveValue() . '" class="form-control daterange" />';
} else {
$htmlFilter = '<input type="text" name="toolbarFilters[' . $col->getUniqueId() . ']" style="width: 80%" value="' . $col->getFilterActiveValue() . '" class="form-control" />';
}
}
?>
<td class="<?php echo implode(',', $classes); ?>">
<?php echo $htmlFilter; ?>
</td>
<?php
}
?>
</tr>
<?php endif; ?>
</thead><!-- END table header -->

<!-- Start table BODY -->
<tbody>
<?php foreach($this->data as $row): ?>
<?php echo $this->bootstrapTableRow($row, $this->columns, $this->rowClickAction, $this->rowStyles, $hasMassActions); ?>
<?php endforeach; ?>
</tbody>
</table>
</div>

<?php echo $this->partial('zfc-datagrid/renderer/bootstrapTable/footer'); ?>
</form>

0 comments on commit 5c08509

Please sign in to comment.