Skip to content

Instantly share code, notes, and snippets.

@iEdzar
Last active April 21, 2017 17:08
Show Gist options
  • Save iEdzar/a8eafb07deb8ac431276dce85ab4f94c to your computer and use it in GitHub Desktop.
Save iEdzar/a8eafb07deb8ac431276dce85ab4f94c to your computer and use it in GitHub Desktop.
https://github.com/lloricode/ci-capstone/tree/a35913562223d00239215bf9b06d473dc1e118db header scrollable conflicts before this commit in dynamic table bootstap: $this->table_bootstrap for ci_capstone
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
Created on : Apr 21, 2017, 11:07:29 PM
Author : Edzar Calibod
*/
.fixed_header{
overflow-y: auto;
height: 700px;
}
<?php
class CI_Capstone_Controller extends MY_Controller
{
/**
*
* @param array $header header
* @param array $table_data_rows rows
* @param string $table_config table bootstrap
* @param string $caption_lang caption
* @param string $pagination | must generated html pagination | default = FALSE
* @param bool $return_html either return html or not
* @return string | generated html table with header/data/table-type/pagination depend on parameters
* @author Lloric Mayuga Garcia <emorickfighter@gmail.com>
*/
public function table_bootstrap($header, $table_data_rows, $table_config_or_template, $header_lang, $pagination = FALSE, $return_html = FALSE, $caption = NULL, $bootsrap = TRUE, $scrollable = TRUE)
{
$this->config->load('admin/table');
$this->load->library('table');
$temp_template = NULL;
if (is_array($table_config_or_template))
{
/**
* if array so its template
*/
$temp_template = $table_config_or_template;
}
else
{
/**
* just table open
*/
$temp_template['table_open'] = $this->config->item($table_config_or_template);
}
if ($scrollable)
{
$th = '<th class="fixed_header">';
$tmp = '<tr>';
foreach ($header as $v)
{
$tmp .= $th . $v . '</th>';
}
$_data['table_open'] = $temp_template['table_open'];
$_data['header'] = $tmp.'</tr>';
$temp_template['heading_cell_start'] = '<td>';
}
if (!$scrollable)
{
$this->table->set_heading($header);
}
$this->table->set_template($temp_template);
$this->table->set_caption($caption);
$_data['header_lang'] = $header_lang;
$_data['table_data'] = $this->table->generate($table_data_rows);
$_data['pagination'] = $pagination;
$_data['bootstrap_output'] = $bootsrap;
$_data['scrollable'] = $scrollable;
$generated_html_table = parent::render('admin/_templates/table', $_data, $return_html);
if ($return_html)
{
return $generated_html_table;
}
}
}
<?php
defined('BASEPATH') OR exit('No direct script allowed');
echo link_tag('assets/custom_ccs/custom_stable_style.css');
if ($bootstrap_output):
?>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class="widget-box">
<div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
<h5><?php echo lang($header_lang); ?></h5>
</div>
<?php if ($scrollable): ?>
<?php echo $table_open; ?>
<?php echo $header; ?>
</table>
<?php endif; ?>
<div class="widget-content nopadding<?php echo ($scrollable) ? ' fixed_header' : ''; ?>">
<?php echo $table_data; ?>
</div>
</div>
</div>
<?php
else:
echo $table_data;
endif;
if (isset($pagination))
{
echo '<div class="pagination alternate pull-right">';
echo $pagination;
echo '</div>';
}
if ($bootstrap_output):
?>
</div>
</div>
<?php
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment