Ignited DataTables |
[eluser]monkeycymbal[/eluser]
Hi!! I have a problem with this useful library. My situation as follows. Datatables library in application/libraries the view with the datatable table: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> the function ajax() in controller "agents" that is called in datatable init Code: function ajax(){ The problem is that table rows does not show up. if I access directly to the function ajax(), the output is: Code: {"sEcho":0,"iTotalRecords":5,"iTotalDisplayRecords":5,"aaData":[["Piero","Maltesino"],["Piero","Maltese"],["piero","Maltese"],["prova","prova"],["Piero","Maltese"]],"sColumns":"name,surname"} Firebug and chrome tools does not show any error. If I use native php ignitedDatatable, it works correctly. Any idea? Thanks ![]()
[eluser]virtualgadjo[/eluser]
hi, @sport_billy sorry to be a little late to answer... may be you could try with 'bProcessing' set to true + "sServerMethod" : "POST" then, as you're using ajax source, you may need to add the function Code: 'fnServerData' : function(sSource, aoData, fnCallback){ last thing, be sure to change this Code: $sSearch = $this->ci->db->escape($this->ci->input->post('sSearch')); Code: $sSearch = $this->ci->input->post('sSearch'); have swing
[eluser]Sport_Billy[/eluser]
[quote author="virtualgadjo" date="1340179436"]hi, @sport_billy sorry to be a little late to answer... may be you could try with 'bProcessing' set to true + "sServerMethod" : "POST" then, as you're using ajax source, you may need to add the function Code: 'fnServerData' : function(sSource, aoData, fnCallback){ last thing, be sure to change this Code: $sSearch = $this->ci->db->escape($this->ci->input->post('sSearch')); Code: $sSearch = $this->ci->input->post('sSearch'); have swing [/quote] Hello and thanks again very much for your help..i made all of the changes you suggested but still nothing shows up if i set "bServerSide": TRUE Have you managed to make it work? If so, can you please give me a sample of your code that works so i can test it?
[eluser]blagi[/eluser]
[quote author="phpstudent" date="1340952817"]where to download Datatables.php[/quote] https://github.com/IgnitedDatatables/Ignited-Datatables
[eluser]phpstudent[/eluser]
hi i am trying to do server side coding, My Controller is post.php <?php class post Extends CI_Controller{ function __construct() { parent::__construct(); } function index() { $this->load->view('main'); } function listener() { $table = 'post'; $columns = array('title', 'category', 'post_date','add_time'); $index = 'id'; $this->load->library('Datatables'); $data['result'] = $this->datatables->generate($table, $columns, $index); echo $data['result']; } function test() { $this->load->view('test'); } } ==========*********========== and View is test.php [removed] $(document).ready(function(){ $('#test_table').dataTable({ 'bServerSide' : true, 'bAutoWidth' : false, 'sPaginationType': 'full_numbers', 'sAjaxSource': 'post/listener', 'aoColumns' : [ { 'sName': 'title'}, { 'sName': 'category'}, { 'sName': 'post_date'}, { 'sName': 'add_time' }, ], 'fnServerData': function(sSource, aoData, fnCallback){ $.ajax({ 'dataType': 'json', 'type': 'POST', 'url': sSource, 'data': aoData, 'success': fnCallback }); }, }); }); [removed] <fieldset> <legend> <b>Search Result</b> </legend> <table cellpadding="0" cellspacing="0" border="0" class="display" id='test_table'> <thead> <tr class="odd gradeX"> <th>Title</th> <th>Category</th> <th>Post Date</th> <th>Added Date</th> </tr> </thead> <tbody> <tr> <td>loading..</td> </tr> </tbody> <tfoot> <tr> <th>Title</th> <th>Category</th> <th>Post Date</th> <th>Added Date</th> </tr> </tfoot> </table> </fieldset> =======*********======= main.php <html> <head> <link rel="stylesheet" href="<?php echo base_url()?>css/master.css"> <link rel="stylesheet" href="<?php echo base_url()?>css/tables.css"> <link rel="stylesheet" href="<?php echo base_url()?>css/iphone-check.css"> <link rel="stylesheet" href="<?php echo base_url()?>css/icons.css"> <link rel="stylesheet" href="<?php echo base_url()?>js/media/css/TableTools.css" type="text/css" /> [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed] $(document).ready(function(){ //$.post("http://localhost/dt_sample/index.php/post/test",function(data){ $.post('post/test', function(data){ $('#target_area').html(data); }); }); [removed] </head> <body> <div class="navigation_button" id='test_button'>Test DataTable with CL Framework</div> <div class="content_area" id="target_area"></div> </body> </html> i am not getting the ouput... so any one can help me
[eluser]blagi[/eluser]
[quote author="phpstudent" date="1341059815"]hi i am trying to do server side coding, My Controller is post.php .... i am not getting the ouput... so any one can help me[/quote] The best way to debug such errors is by using Firefox Firebug or Webkit development tools. There is a "Net" tab within which you can see what your server side function returns: either data or some html with errors.
[eluser]cryogenix[/eluser]
[quote author="phpstudent" date="1341059815"]hi i am trying to do server side coding, My Controller is post.php <?php class post Extends CI_Controller{ function __construct() { parent::__construct(); } function index() { $this->load->view('main'); } function listener() { $table = 'post'; $columns = array('title', 'category', 'post_date','add_time'); $index = 'id'; $this->load->library('Datatables'); $data['result'] = $this->datatables->generate($table, $columns, $index); echo $data['result']; } function test() { $this->load->view('test'); } } ==========*********========== and View is test.php [removed] $(document).ready(function(){ $('#test_table').dataTable({ 'bServerSide' : true, 'bAutoWidth' : false, 'sPaginationType': 'full_numbers', 'sAjaxSource': 'post/listener', 'aoColumns' : [ { 'sName': 'title'}, { 'sName': 'category'}, { 'sName': 'post_date'}, { 'sName': 'add_time' }, ], 'fnServerData': function(sSource, aoData, fnCallback){ $.ajax({ 'dataType': 'json', 'type': 'POST', 'url': sSource, 'data': aoData, 'success': fnCallback }); }, }); }); [removed] <fieldset> <legend> <b>Search Result</b> </legend> <table cellpadding="0" cellspacing="0" border="0" class="display" id='test_table'> <thead> <tr class="odd gradeX"> <th>Title</th> <th>Category</th> <th>Post Date</th> <th>Added Date</th> </tr> </thead> <tbody> <tr> <td>loading..</td> </tr> </tbody> <tfoot> <tr> <th>Title</th> <th>Category</th> <th>Post Date</th> <th>Added Date</th> </tr> </tfoot> </table> </fieldset> =======*********======= main.php <html> <head> <link rel="stylesheet" href="<?php echo base_url()?>css/master.css"> <link rel="stylesheet" href="<?php echo base_url()?>css/tables.css"> <link rel="stylesheet" href="<?php echo base_url()?>css/iphone-check.css"> <link rel="stylesheet" href="<?php echo base_url()?>css/icons.css"> <link rel="stylesheet" href="<?php echo base_url()?>js/media/css/TableTools.css" type="text/css" /> [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed] $(document).ready(function(){ //$.post("http://localhost/dt_sample/index.php/post/test",function(data){ $.post('post/test', function(data){ $('#target_area').html(data); }); }); [removed] </head> <body> <div class="navigation_button" id='test_button'>Test DataTable with CL Framework</div> <div class="content_area" id="target_area"></div> </body> </html> i am not getting the ouput... so any one can help me[/quote] hi there, sorry for the late reply but the version of IgnitedDatatables you are using has long been outdated and is kind of deprecated. you may get the latest version on out github page at: https://github.com/IgnitedDatatables/Ign...atatables/ and consult the wiki section there for usage guide.
[eluser]Unknown[/eluser]
Hi There, I am using datatables in admin panel. I had one issue with this. Can you please tell me how to modify data before displaying it. or before passing it to the client as json data. For Example: in my table created and modify date is there which i want to display in another format say total seconds to may be and GMT or human readable form, Another Example: suppose i have path or name of the image into database table now i want to display it as image with img and a tag. Can you please tell me how can i do this.. Thanks
[eluser]ηυмвєяσηє[/eluser]
Hi Vaibhav, 1. Date parsing : You have two option: a. run sql command to get modified date. run: SELECT DATE_FORMAT(column_name, '%d/%m/%Y') as myNewDate FROM tablename or simply: Code: public function test() { b. Make a helper file and run a callback function with edit function like this : http://ellislab.com/forums/viewthread/16...80/#956865 and your helper function will be like : http://ellislab.com/forums/viewthread/16...80/#956911 2. same solution with 1. some examples for native version of the library. You can adapt this for codeigniter. see differences between date columns http://numberone.kodingen.com/datatables...filtering/ http://numberone.kodingen.com/datatables...iltering2/ |
Welcome Guest, Not a member yet? Register Sign In |