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

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

[eluser]Unknown[/eluser]
Is there an example of how to go to a page where a specific row exists?

[eluser]ahadyekta[/eluser]
I have problem when using second custom query between datatables controller .
this is my controller :
Code:
function sell_table(){
  
  $this->load->library('datatables');
  $this->datatables->select("id");
  $this->datatables->add_column('product',$this->sell_model->get_product_info('$1') , 'id');
  $this->datatables->select("sale_value,final_price,date,status");
  $this->datatables->from("sell");
  $this->datatables->where('customer_id', '1');
  $result=$this->datatables->generate();
  echo $result;
  
}

get_product_info function get some information about products from database for each row (get the id of each sell and return some info) , it works when I call it directly but when use it in between these statments it shows database error from codeigniter , How can I use Custom query betwen datatables`s statments ?

[eluser]Unknown[/eluser]
Hi all,

First of all thanks for the nice libary!

But I have one question, I want to add 2 columns at the beginning of the table, but when I do $this->datatables->add_column() it place this column at the end of the table.

Can someone help me?

Thanks

[eluser]ηυмвєяσηє[/eluser]
Use mDataProp

Code:
[removed]
$(document).ready(function()
  {
    $('#example').dataTable
    ({
      'bServerSide'    : true,
      'sAjaxSource'    : 'ajax.php',
      'aoColumns': [
        { "mDataProp": "edit", 'bSortable': false },
        { "mDataProp": "delete" , 'bSortable': false},
        { "mDataProp": "first_name" },
        { "mDataProp": "last_name" },
        { "mDataProp": "email"},
       ],
      'fnServerData': function(sSource, aoData, fnCallback) {
    $.ajax(
    {
     'dataType': 'json',
     'type'    : 'POST',
     'url'     : sSource,
     'data'    : aoData,
     'success' : fnCallback
    });
   }
    });
  });
[removed]

[eluser]Johan N.[/eluser]
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

[eluser]Unknown[/eluser]
Hello!

Ive been following this example:
http://vimeo.com/25273887

Im just trying to do the basics, got an external MySQL database which I configured in application/config/database.php (I've tried getting data from it using only php and html and it worked fine)

Here's the view, without the html:

Code:
[removed]
   $(document).ready(function() {
    $('#example').dataTable( {
                                    "bProcessing": true,
                                    "bServerSide": true,
                                    "sAjaxSource": "&lt;?php base_url(); ?&gt;site/getdatabyajax",
                                    "fnServerData": function(sSource, aoData, fnCallback) {
                                        $.ajax({
                                            "dataType": 'json',
                                            "type": "POST",
                                            "url": sSource,
                                            "data": aoData,
                                            "success": fnCallback
                                        });
                                    }                              
                                });
                            });
                [removed]

And the controller:

Code:
class Site extends CI_Controller {

public function index()
{
  $this->load->view('post');
}
        public function getdatabyajax()
        {
            $this->load->library('Datatables');
            $this->datatables
                    ->select('name,surname,mail,address')
                    ->from('customers');
            echo $this->datatables->generate();
        }
}

But no data will be displayd in the DataTable.. any ideas? any help of how to debug or experiences are appreciated. Isnt it possible to do this without having a model?

Chromium console says:
POST http://localhost:1234/codeigniter/site/getdatabyajax 404 (Not Found)

Edit: I know I configure codeigniter to be able to run the controllers methods. I've really tried everything now it seems like.. ive made som changes and im now getting the error:
" Failed to load resource http://localhost/codeigniter/index.php/s...databyajax " in the chromium console. Anyone sitting on some example-code that is working?

Dont know if it helps..

Thank you.

[eluser]nmoynihan[/eluser]
I am trying to output some data formatted differently for each row, using $this->datatables->add_column(); but it is not working for some reason.

Controller Code:
Code:
$this->datatables->select('project_id, name, status, end_date')
->unset_column('end_date');
   $this->datatables->add_column('end_date', check_deadline('$1'), 'end_date')    
   $this->datatables->from('projects');
   echo $this->datatables->generate();
Helper Function:
Code:
function check_deadline($date)
{
  if (trim($date) == '0000-00-00')
  {
   return "Ongoing";
  }
  else
  {
   return trim($date);
  }
}

As the end result, I either get EVERY row to say 'Ongoing' or as the actual date, including if it is 0000-00-00.

Am I using this function in the wrong way? Any help greatly appreciated.

EDIT: So I am thinking this function just gets evaluated once, and the variable replacement is done AFTER the function is evaluated. Is there a way I can make it do what I want? Thanks!

[eluser]ηυмвєяσηє[/eluser]
>add_column('end_date', '$1', 'check_deadline("end_date")')

>add_column('end_date', '$1 $2', 'check_deadline("end_date") , status')

The usage is like this.

[eluser]nmoynihan[/eluser]
[quote author="ηυмвєяσηє" date="1375808585"]>add_column('end_date', '$1', 'check_deadline("end_date")')

>add_column('end_date', '$1 $2', 'check_deadline("end_date") , status')

The usage is like this. [/quote]

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB