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

[eluser]ninjayan[/eluser]
I'm using this code to order the datetime
Code:
"aaSorting": [[2, "desc"]]
Now I want to order datetime on query and this is my code
Code:
$this->load->library('datatables');
  $this->datatables
     ->select("user_id, details, datetime")
                                        ->order_by("datetime", "desc")
     ->from("logs");
  echo $this->datatables->generate();
but its not working.

[eluser]johnwbaxter[/eluser]
Are callbacks still available in v 0.7?

I've got

Code:
->edit_column('amount_paid', '$1', 'callback_number_format(amount_paid|2)');

But it just renders that back to me in the datatable cell without processing it.

Code:
callback_number_format(amount_paid|2)

Any ideas?

Thanks Smile

[eluser]ninjayan[/eluser]
Hello.

How can I refresh the table after I delete a data?
the code is at the controller using the onclick.

When adding data, I use the fnDraw to refresh the table.

[eluser]bradhawk[/eluser]
Anyone has implemented it with HTML Form?
I has a Form and the Table on the same page, and I wanted to use the form to Filtering data from SQL and when I press Submit, it refresh with the Table updated.

My Model "List.php" :
Code:
function number_list($startdate, $enddate, $number)
{
  $this->load->library('datatables');

  $this->datatables
   ->select('date, number, status')
   ->from('trans')
   ->where('date >=', $startdate)
   ->where('date <=', $enddate)
   ->where('number', $number);

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

My Controller :
Code:
function get_result()
{
  $this->load->model('list','',TRUE);

  $startdate = $this->input->post('range1');
  $enddate = $this->input->post('range2');
  $number = $this->input->post('number');

  echo $this->list->number_list($startdate, $enddate, $number);
}

I'm stuck to update it to the DataTables using the POST Ajax.
I have no idea to figure it out, any help will be appreciated.

Thanks Big Grin

[eluser]ηυмвєяσηє[/eluser]
@johnwbaxter

yup.. now without "callback_" prefix and "|" seperator..
Code:
->edit_column('amount_paid', '$1', 'number_format("amount_paid","2")');
or
Code:
->edit_column('amount_paid', '$1', 'number_format(amount_paid,2)');

this should work..

[eluser]bradhawk[/eluser]
anyone?
help me, please. Smile

thanks

[eluser]bradhawk[/eluser]
Hello.

I googling and found thing that I need, but after using the code, my table not rendered completely.
My Table Code :
Code:
[removed]
$(document).ready(function() {
  oTable = $('#transaksiAJAX').dataTable({
   "bJQueryUI": true,
   "sPaginationType": "full_numbers",
   "bFilter": false,
   "bSort": false,
   "bProcessing": true,
   "bServerSide": true,
   "sAjaxSource": "&lt;?=base_url()?&gt;member/get_result"
   "fnServerData": function(sSource, aoData, fnCallback) {
    oTable.push({ "name": "range1", "value": $( "#range1" ).val() },
       { "name": "range2", "value": $( "#range2" ).val() },
       { "name": "nomer", "value": $( "#nomer" ).val() } );
    $.ajax(
    {
     'dataType': 'json',
     'type'    : 'POST',
     'url'     : sSource,
     'data'    : aoData,
     'success' : fnCallback
    });
   }
  });
} );
[removed]

What's wrong with the code?

thanks

[eluser]ηυмвєяσηє[/eluser]
"sAjaxSource": "&lt;?=base_url()?&gt;member/get_result"
"fnServerData": function(sSource, aoData, fnCallback) {


there are no commas between those lines.

[eluser]bradhawk[/eluser]
Thanks! It's working now Smile

[eluser]brizoo[/eluser]
Hi everyone,

First of all, thanks for this implementaition, I love the idea of having a library for doing datatables. This is a great tool which make everything easier.

I spent all the day trying to make it work without succes and this is honestly making me a bit crazy.

I have read the whole post on this forum, and a lot of documentation on the official website of datatables plugin, I've found a lot of examples, but nothing working for me.

I have implemented a very simple example.

Here is the code :

My view : datatables.php
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
&lt;html&gt;
&lt;head&gt;
  &lt;meta http-equiv="content-type" c charset=utf-8" /&gt;  
  &lt;title&gt;DataTables example&lt;/title&gt;
&lt;link rel="stylesheet" href="&lt;?php echo base_url(); ?&gt;public/css/demo_page.css" type="text/css" media="screen" /&gt;
  &lt;link rel="stylesheet" href="&lt;?php echo base_url(); ?&gt;public/css/demo_table.css" type="text/css" media="screen" /&gt;
  [script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"][/script]
  [script src="&lt;?php echo base_url(); ?&gt;public/js/jquery.dataTables.min.js"][/script]
&lt;/head&gt;
&lt;body&gt;  
  <div  id="dt_example">
   <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <thead>
     <tr>
      <th width="20%">Id</th>
      <th width="25%">Name</th>
      <th width="25%">Description</th>
     </tr>
    </thead>
    <tbody>
     <tr>
      <td colspan="5" class="dataTables_empty">Loading data from server</td>
     </tr>
    </tbody>
    <tfoot>
     <tr>
      <th>Id</th>
      <th>Name</th>
      <th>Description</th>
     </tr>
    </tfoot>
   </table>
  </div>
  [script]
   $(document).ready(function() {
     $('#example').dataTable( {
         "bProcessing": true,
         "bServerSide": true,
         "sAjaxSource": "&lt;?=base_url()?&gt;datatables/get_list"
     });
});
  [/script]
&lt;/body&gt;
&lt;/html&gt;

My controller :
Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Datatables extends CI_Controller
{
function __construct()
{
  parent::__construct();
}

public function index()
{
  $this->load->view('datatables');
}

function get_list()
{
  $this->load->model('datatables','',TRUE);
  
  echo $this->datatables->list_all();
}
}

My Model :

Code:
&lt;?php
class Datatables extends CI_Model {


function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function list_all()
{
  $this->load->library('datatables');
  
  $this->datatables
       ->select('id, name, description')
       ->from('groups');
  
  return $this->datatables->generate();
}


}

The problem is when, I'm lauching the example like this : http://poplidays/datatables

I have the table empty, with the message "Processing". Looking into Firebug gave me a 500 Internal Server Error on this GET request :

http://poplidays/datatables/get_list?sEc...3562912120

I have tried a lot of stuffs to make it work and each time I include the datatables library like this I have a 500 Internal Server Error


Would someone help me Smile ?

Thanks a lot guys




Theme © iAndrew 2016 - Forum software by © MyBB