One of the best ways to learn how to create Data Table in codeigniter.
First we need to call two JS that is
1.jquery.dataTables.js
2. dataTables.bootstrap.js
Than write the view in codeigniter like this you also need towrite jq('#example1').dataTable();.
Benifite:
DataTables ColumnFilter plugin add filtering boxes into the table footer.
1 Auto pagination at the page.
2 Auto seach in the table fields
<!-- DATA TABES SCRIPT -->
<script src="<?php echo base_url(); ?>js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
<!-- page script -->
<script type="text/javascript">
var jq = $.noConflict();
jq(document).ready(function() {
jq('#example1').dataTable();
} );
</script>
<table id="example1" class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Class</th>
<th>Course</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $row=explode(',',$my_data[0]['T_timetale_desc']); ?>
<tr>
<td><?php echo $my_data[0]['TimeTable_id']; ?></td>
<td><?php echo $my_data[0]['T_class']; ?></td>
<td><?php echo $my_data[0]['T_course']; ?></td>
<td><?php echo $row[0]; ?></td>
<td>
<a href="<?php echo base_url() ?>timetable/edit/<?php echo $row['TimeTable_id']; ?>" class="btn btn-primary btn-sm">Edit</a>
<a href="<?php echo base_url() ?>timetable/single_timetable/<?php echo $row['TimeTable_id']; ?>" class="btn btn-primary btn-sm">View</a>
</div></td>
</tr>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Class</th>
<th>Course</th>
<th>Status</th>
<th>Action</th>
</tr>
</tfoot>
</table>
First we need to call two JS that is
1.jquery.dataTables.js
2. dataTables.bootstrap.js
Than write the view in codeigniter like this you also need towrite jq('#example1').dataTable();.
Benifite:
DataTables ColumnFilter plugin add filtering boxes into the table footer.
1 Auto pagination at the page.
2 Auto seach in the table fields
<!-- DATA TABES SCRIPT -->
<script src="<?php echo base_url(); ?>js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
<!-- page script -->
<script type="text/javascript">
var jq = $.noConflict();
jq(document).ready(function() {
jq('#example1').dataTable();
} );
</script>
<table id="example1" class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Class</th>
<th>Course</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $row=explode(',',$my_data[0]['T_timetale_desc']); ?>
<tr>
<td><?php echo $my_data[0]['TimeTable_id']; ?></td>
<td><?php echo $my_data[0]['T_class']; ?></td>
<td><?php echo $my_data[0]['T_course']; ?></td>
<td><?php echo $row[0]; ?></td>
<td>
<a href="<?php echo base_url() ?>timetable/edit/<?php echo $row['TimeTable_id']; ?>" class="btn btn-primary btn-sm">Edit</a>
<a href="<?php echo base_url() ?>timetable/single_timetable/<?php echo $row['TimeTable_id']; ?>" class="btn btn-primary btn-sm">View</a>
</div></td>
</tr>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Class</th>
<th>Course</th>
<th>Status</th>
<th>Action</th>
</tr>
</tfoot>
</table>
No comments:
Post a Comment