Welcome Guest, Not a member yet? Register   Sign In
Ignited DataTables

[eluser]bluehat09[/eluser]
Thanks!

[quote author="ahmed.samy" date="1363816066"]I have created a small tutorial for how to use ignited datatables, hope it helps you
http://www.ahmed-samy.com/codeigniter-fu...atatables/[/quote]

[eluser]ninjayan[/eluser]
Code:
"sAjaxSource": "<?php echo base_url(); ?>document_directory/get_transactions",

This line of js datatable is used for getting records. My concern now is how can I protect the controller function in getting transactions because everyone can directly access the controller function and show all the records.

[eluser]cryogenix[/eluser]
[quote author="Johan N." date="1370232983"]Hi, i switched to start using this library but im having an (maybe noobie) issue. The library always returns 100 rows when I have 3000+ in the table I want to show, here is what I got using the original script and processing the results in the view with a foreach loop:

Quote:Showing 1 to 20 of 3080 entries

And with this library i got this:

Quote:Showing 1 to 20 of 100 entries

Edit:
Im adding the code so anyone can have a better idea and help me.

This is in my view, the sDom parameter is something to do with the bootstrap framework:
Code:
$('#peopletable').dataTable( {
                "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
                "aaSorting": [[1,'asc']],
                "oLanguage": spanish,
                "sPaginationType": "bootstrap",
                "iDisplayLength": 20,
                "bProcessing": true,
                "bServerSide": false,
                "sAjaxSource": "pacientes/json_people",
                "fnServerData": function(sSource, aoData, fnCallback){
                     $.ajax ({
                      'dataType': 'json',
                      'type'    : 'POST',
                      'url'     : sSource,
                      'data'    : aoData,
                      'success' : fnCallback
                     });
                    }
            });

And this is the json_people function in my controller:
Code:
function json_people()
{
  $this->load->library('Datatables');
  $this->datatables
      ->select('[removed fields]')
      ->from('people');

  echo $this->datatables->generate();
}

Im sorry if this have something to do with some basic parameter I just dont know how to make it work. Also Im working with postgresql so I dont know either if this could be some pg related issue.

Edit: Forgot to ask about something else, i cant make this work when i set "bServerSide": true[/quote]

hi there. this issue has been resolved as of the latest push (thanks to blyxx86). please update your copy of ignited datatables.

[eluser]ninjayan[/eluser]
I randomly get 403 Forbidden error when using the datatables search feature. I don't know why? Server timeout?

[eluser]Unknown[/eluser]
Hi All,

I use codeigniter and datatables i have a problem when i use group_by(), my tables has show 10 rows only but on the bottom of the tables it says "Showing 1 to 10 of 15 entries"

is group_by() is not grouping properly?

if the records are not group then there is 15 rows, but i need to group by name so after grouping it will who only 10 rows but on the bottom says 15 total entries.

Please help.

[eluser]afirdaus[/eluser]
hi i got problem with edit_column

user_m.php (model file)
Code:
function getListpppmbPaging()
{
     $this->load->library('datatables');
     $this->datatables->select('*,BARANG_TGL_REG')->from('tb_barang');
     $this->datatables->where('BARANG_STATUS !=','BATAL');
     $this->datatables->where('BARANG_STATUS !=','SELESAI');
     $this->datatables->edit_column('BARANG_TGL_REG', '$1','waktuid("BARANG_TGL_REG")');
     return $this->datatables->generate();
}

function waktuid($tgl){
$tahun = substr($tgl,0,4);
$bulan = substr($tgl,5,2);
$tanggal = substr($tgl,8,2);
        $tglnya = date("d-M-Y H:i:s",strtotime($tgl));
        $jam = substr($tgl, 11,5);
$lengkap=$tanggal.'-'.$bulan.'-'.$tahun.' '.$jam;
         return $lengkap;  
}

but datatable shown "waktuid("BARANG_TGL_REG")" in column, and then i tried
Code:
$this->datatables->edit_column('BARANG_TGL_REG', '$1','callback_waktuid("BARANG_TGL_REG")');

or
Code:
$this->datatables->edit_column('BARANG_TGL_REG', '$1','$this->waktuid("BARANG_TGL_REG")');

the result is same..

i think call_user_func_array in exec_replace function datatables.php file only identifier built in php function like trim, substr, etc..

please help me how parsing local function from edit_column.


Thanks, sorry my english is bad

[eluser]afirdaus[/eluser]
[quote author="afirdaus" date="1377729247"]hi i got problem with edit_column

user_m.php (model file)
Code:
function getListpppmbPaging()
{
     $this->load->library('datatables');
     $this->datatables->select('*,BARANG_TGL_REG')->from('tb_barang');
     $this->datatables->where('BARANG_STATUS !=','BATAL');
     $this->datatables->where('BARANG_STATUS !=','SELESAI');
     $this->datatables->edit_column('BARANG_TGL_REG', '$1','waktuid("BARANG_TGL_REG")');
     return $this->datatables->generate();
}

function waktuid($tgl){
$tahun = substr($tgl,0,4);
$bulan = substr($tgl,5,2);
$tanggal = substr($tgl,8,2);
        $tglnya = date("d-M-Y H:i:s",strtotime($tgl));
        $jam = substr($tgl, 11,5);
$lengkap=$tanggal.'-'.$bulan.'-'.$tahun.' '.$jam;
         return $lengkap;  
}

but datatable shown "waktuid("BARANG_TGL_REG")" in column, and then i tried
Code:
$this->datatables->edit_column('BARANG_TGL_REG', '$1','callback_waktuid("BARANG_TGL_REG")');

or
Code:
$this->datatables->edit_column('BARANG_TGL_REG', '$1','$this->waktuid("BARANG_TGL_REG")');

the result is same..

i think call_user_func_array in exec_replace function datatables.php file only identifier built in php function like trim, substr, etc..

please help me how parsing local function from edit_column.


Thanks, sorry my english is bad
[/quote]


i got temporary solution until i got another solutions from here

i copied waktuid function to datatables.php, then i call edit_column like this
Code:
$this->datatables->edit_column('BARANG_TGL_REG', '$1','call_user_func_array("waktuid", BARANG_TGL_REG)');

after that, i modified function exec_replace in datatables.php
Code:
$replace_string = @call_user_func_array($func, $args);
//var_dump($args);
if($args[0] == "waktuid"){
$replace_string = $this->waktuid($args[1]);
}

and it work..but i'm still waiting the best solutions from here..

Thanks..

[eluser]ηυмвєяσηє[/eluser]
Hi afirdaus,

Put that function into a helper file. Then load the helper file before the datatables library.

[eluser]stefenw[/eluser]
hello

i am newbie in codeigniter and datatables , i need your help.

i use latest ignited datatables with mssql database,

every function is work for me except paging,

first display it work fine with 10 display record,when i click page 2 its display 1-20 records,page 3 display 1-30 records.

please help

paging in datatables

Code:
private function get_paging() {
        $iStart = $this->ci->input->post('iDisplayStart');
        $iLength = $this->ci->input->post('iDisplayLength');

        if ($iLength != '' && $iLength != '-1')
            $this->ci->db->limit($iLength, ($iStart) ? $iStart : 0);
    }

initialization

Code:
var oTable = $('#big_table').dataTable( {
  "bProcessing": true,
  "bServerSide": true,
  "sAjaxSource": '&lt;?php echo base_url(); ?&gt;index.php/subscriber/datatable',
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "iDisplayStart ":20,
                "oLanguage": {
            "sProcessing": "<img src='&lt;?php echo base_url(); ?&gt;assets/images/ajax-loader_dark.gif'>"
        },  
        "fnInitComplete": function() {
                //oTable.fnAdjustColumnSizing();
         },
                'fnServerData': function(sSource, aoData, fnCallback)
            {
              $.ajax
              ({
                'dataType': 'json',
                'type'    : 'POST',
                'url'     : sSource,
                'data'    : aoData,
                'success' : fnCallback
              });
            }
} );


controller

Code:
function datatable()
    {
        $this->datatables->select('nik,nama,nickname')
        ->from('dbo.tb_mt_PIM');
        
        echo $this->datatables->generate();
    }

[eluser]Unknown[/eluser]
I am trying to get DataTables to work server side. My program is running upwards of 200.000 elements that i need to filter out now, and IE is having a hard time rendering a table with that many elements.

So far i have setup the following:

JS:
Code:
var testTable = $('#example').dataTable( {
  "bProcessing": true,
  "bServerSide": true,
  "sAjaxSource": "&lt;?php echo base_url(); ?&gt;search/serverSide"
} );

Controller:
Code:
function serverSide(){
    
   $this->load->library('datatables');
        
        $this->datatables->select('id, title,description, created, updated');
        $this->datatables->from('tickets');
          
        
        echo $this->datatables->generate();
                      
      
    }

HTML:
Code:
<table id="example">
                    <thead>
                        <tr>
                            <th>id</th>
                            <th>title</th>
                                <th>description</th>
                                <th>created</th>
                                <th>updated</th>
                        
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td colspan="3">Loading Data</td>
                        </tr>
                    </tbody>
                </table>


This works fine with bServerSide:false, but i want this to work with bServerSide:true.

How can i get this to work?

I assume that with bServerSide:false it only outputs directly the ajax-response i am getting at myURL/search/serverSide

Any ideas? Do i need to implement any other libraries




Theme © iAndrew 2016 - Forum software by © MyBB