Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table class="table table-bordered table-striped" id="mytable">
- <thead>
- <tr>
- <th width="80px">No</th>
- <th>Judul</th>
- <th>Link</th>
- <th>Icon</th>
- <th>IsParent</th>
- <th>Status Aktif</th>
- <th width="100px">Action</th>
- </tr>
- </thead>
- </table>
- <script src="<?php echo base_url('assets/js/jquery-1.11.2.min.js') ?>"></script>
- <script src="<?php echo base_url('assets/datatables/jquery.dataTables.js') ?>"></script>
- <script src="<?php echo base_url('assets/datatables/dataTables.bootstrap.js') ?>"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings)
- {
- return {
- "iStart": oSettings._iDisplayStart,
- "iEnd": oSettings.fnDisplayEnd(),
- "iLength": oSettings._iDisplayLength,
- "iTotal": oSettings.fnRecordsTotal(),
- "iFilteredTotal": oSettings.fnRecordsDisplay(),
- "iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
- "iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
- };
- };
- var t = $("#mytable").dataTable({
- initComplete: function() {
- var api = this.api();
- $('#mytable_filter input')
- .off('.DT')
- .on('keyup.DT', function(e) {
- if (e.keyCode == 13) {
- api.search(this.value).draw();
- }
- });
- },
- oLanguage: {
- sProcessing: "loading..."
- },
- processing: true,
- serverSide: true,
- ajax: {"url": "menu_super_admin/json", "type": "POST"},
- columns: [
- {
- "data": "id",
- "orderable": false
- },{"data": "judul"},{"data": "link"},{"data": "icon"},{"data": "IsParent"},
- {
- if("data": "status_aktif"=='y'){
- "data": 'Aktif'
- }
- else{
- "data": 'Nonaktif'
- }
- },
- {
- "data" : "action",
- "orderable": false,
- "className" : "text-center"
- }
- ],
- order: [[0, 'desc']],
- rowCallback: function(row, data, iDisplayIndex) {
- var info = this.fnPagingInfo();
- var page = info.iPage;
- var length = info.iLength;
- var index = page * length + (iDisplayIndex + 1);
- $('td:eq(0)', row).html(index);
- if(data.status_aktif == "y"){
- status_aktif = "Aktif";
- }else{
- status_aktif = "Nonaktif";
- }
- $('td:eq(5)', row).html(status_aktif);
- }
- });
- });
- </script>
Add Comment
Please, Sign In to add comment