ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Ignited DataTables

July 15, 2010 2:51am

Subscribe [119]
  • #436 / Oct 11, 2013 4:04pm

    rogertcd

    2 posts

    I found a solution for my issue, I just made a view in the DataBase with all columns required in my application and it’s all.

    Now I have another issue, I’m working with a Oracle Database, and I want to compare a range of dates for example:

    $this->datatables->select("ID_E, NAME, SNAME, BIRTHDATE")
                        ->add_column('OPTIONS', '$1','get_buttons(ID_E)')
                        ->from('EMPLOYEES')->where('BIRTHDATE between "01/01/1985" and "31/12/1998"');
    echo $this->datatables->generate();

    it produces an error:

    Fatal error</b>:  Call to a member function num_rows() on a non-object in ...

    How can I introduce proper functions of Oracle in “where” condition? for example to_date()
    I want to make something like the following:

    $this->datatables->select("ID_E, NAME, SNAME, BIRTHDATE")
                        ->add_column('OPTIONS', '$1','get_buttons(ID_E)')
                        ->from('EMPLOYEES')->where('BIRTHDATE between to_date("01/01/1985","dd/mm/yyyy") and to_date("31/12/1998","dd/mm/yyyy")');
    echo $this->datatables->generate();
  • #437 / Jan 28, 2014 9:31am

    Hayezb

    2 posts

    I’ve been using Ignited Datatables and love it so far, but I guess I’m a little confused with the JOIN feature. This is what I’m trying to use:

    Controller:

    public function tableload(){
      
      $this->load->database();
      $this->load->library('Datatables');
      $this->datatables->select('INVENTORY_PRODUCTS.ID, INVENTORY_PRODUCTS.PRODUCTNAME, INVENTORY_PRODUCTS.MODELNUMBER, MANUFACTURER.COMPANYNAME');
      $this->datatables->from('INVENTORY_PRODUCTS');
      $this->datatables->join('MANUFACTURER', 'MANUFACTURER.ID ON INVENTORY_PRODUCTS.MANUFACTURERID', 'LEFT');
      //$this->datatables->select('COMPANYNAME');
      $this->datatables->add_column('edit', '<a href="http://view_inventory/inventory_info/$1">view</a>', 'ID');
      
      echo $this->datatables->generate();
      
     }

    View:

    $(document).ready(function() {
                      $('#inventory').dataTable( { 
                           "sPaginationType": "bs_normal",
                           "bProcessing": true,
                           "bServerSide": true,
                           "sAjaxSource": "<?php echo base_url('inventory/tableload')?>",
                           "sServerMethod": "POST",
                           "aoColumnDefs": { "bVisible": false, "aTargets": [0]}
                       } );
                   } );

    I’m getting a POST 500 Internal Server Error.

  • #438 / Jan 30, 2014 5:09pm

    srgoldman

    1 posts

    I ran into a problem using IgnitedDatatables with a table having over 200K entries. Even though it was paginating properly, the get_total_results calls (there are two - one with filtering and one without) were retrieving the entire table just to calculate the number of rows that the query would return. I modified the method to the following and now it performs much more acceptably.

    private function get_total_results($filtering = FALSE)
        {
            if ($filtering)
                $this->get_filtering();
    
            foreach ($this->joins as $val)
                $this->ci->db->join($val[0], $val[1], $val[2]);
    
            foreach ($this->where as $val)
                $this->ci->db->where($val[0], $val[1], $val[2]);
    
            foreach ($this->or_where as $val)
                $this->ci->db->or_where($val[0], $val[1], $val[2]);
    
            foreach ($this->group_by as $val)
                $this->ci->db->group_by($val);
    
            foreach ($this->like as $val)
                $this->ci->db->like($val[0], $val[1], $val[2]);
    
            if (strlen($this->distinct) > 0)
            {
                $this->ci->db->distinct($this->distinct);
                $this->ci->db->select($this->columns);
            }
            // These two lines are the key difference
            $this->ci->db->from($this->table);
            return $this->ci->db->count_all_results();
        }
  • #439 / Feb 26, 2014 9:44am

    OussamaG

    1 posts

    Hi! Thanks for the library!
    I have an issue. The edit_column function doesn’t work properly when i use callback_function.


    In this case, it always returns “Error” but when i type return $str it gets the real string passed as a parameter.
    Did i miss something here?

    Thanks.

    The code:

    ->edit_column('releve_statut', '$1', $this->label_this("releve_statut"))
    public function label_this($str) {
            /**/
              if($str == "Réalisé"){
              $r =  'AAA';
              } else if ($str == "En cours"){
              $r = 'BBB';
              } else {
              $r = 'Error';
              }
              /* */
            return $r;
        }
  • #440 / Apr 23, 2014 1:25am

    onlyjf

    2 posts

    I’ve been using Ignited Datatables and love it so far, but I guess I’m a little confused with the JOIN feature. This is what I’m trying to use:

    Controller:

    public function tableload(){
      
      $this->load->database();
      $this->load->library('Datatables');
      $this->datatables->select('INVENTORY_PRODUCTS.ID, INVENTORY_PRODUCTS.PRODUCTNAME, INVENTORY_PRODUCTS.MODELNUMBER, MANUFACTURER.COMPANYNAME');
      $this->datatables->from('INVENTORY_PRODUCTS');
      $this->datatables->join('MANUFACTURER', 'MANUFACTURER.ID ON INVENTORY_PRODUCTS.MANUFACTURERID', 'LEFT');
      //$this->datatables->select('COMPANYNAME');
      $this->datatables->add_column('edit', '<a href="http://view_inventory/inventory_info/$1">view</a>', 'ID');
      
      echo $this->datatables->generate();
      
     }

    View:

    $(document).ready(function() {
                      $('#inventory').dataTable( { 
                           "sPaginationType": "bs_normal",
                           "bProcessing": true,
                           "bServerSide": true,
                           "sAjaxSource": "<?php echo base_url('inventory/tableload')?>",
                           "sServerMethod": "POST",
                           "aoColumnDefs": { "bVisible": false, "aTargets": [0]}
                       } );
                   } );

    I’m getting a POST 500 Internal Server Error.

     

    Please see below source.
    You have to add csrf value for the form validation

    'fnServerData': function (sSource, aoData, fnCallback) {
                    // ajax post csrf send. 
                     var csrf = {"name": "<?php echo $this->security->get_csrf_token_name(); ?>", "value":$.cookie('<?php echo $this->config->item("csrf_cookie_name"); ?>')};
                     aoData.push(csrf);
            
                    $.ajax
                    ({
                        'dataType': 'json',
                        'type': 'POST',
                        'url': sSource,
                        'data': aoData,
                        'success': fnCallback
                    });
                }
  • #441 / Apr 30, 2014 4:03am

    Jeroma

    3 posts

    Hello,
    thank you for the excellent library. It helped me a lot.
    Here is adapted for work with PostgreSQL library. Also I did this improvements:
    - added here two “virtual” methods produce_cell and produce_row to allow descendands to manipulate cell values and completed rows.
    - added additional constructor parameter $hiddenColumns. This columns aren’t shown in the result output but you may access theirs values to compute something.
    - The library handles SQL like ‘field1 as f1’ in ordering and filtering.

    File is too big for the post and I attached it as zip file.

  • #442 / Jul 03, 2014 3:24am

    macmaina

    1 posts

    Hi,
    Am having a problem with displaying data onto the table. The model return a well formatted json but i get an error:

    DataTables warning (table id = 'my_id'): Requested unknown parameter '0' from the data source for row 0

    my model:

    function customer_data() {
    
    
      $this->datatables->select("full_name, email");
      $this->datatables->from($this->table_name);
      return $this->datatables->generate('json', 'ISO-8859-1');
     }

    My js:

    $(document).ready(function() {
        $('#my_id').dataTable( {
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "http://localhost/customer/get_customers",
            'sAjaxDataProp': 'data',
            'fnServerData': function(sSource, aoData, fnCallback){
                $.ajax({
                    'dataType': 'json',
                    'type'    : 'POST',
                    'url'     : sSource,
                    'data'    : aoData,
                    'success' : function(res){
                     console.log〈res.data〉;
                     fnCallback(res);
                    }
                });
            }
        });
    });

    html:

    <table id="my_id">
             <thead>
                <tr>
                 
                    <th>full_name</th>
                    <th>email</th>
                    
                </tr>
            </thead>
    
             
            </table>

    What could be the problem or What am i missing?

  • #443 / Jul 14, 2014 6:37pm

    trta911

    4 posts

    Hi, I’m new to ignited datatables. Because I have a lot of rows at database, i need server-side scripting and ajax data load so ignited datatables is good option. But i have little problem with edit_column function.
    I found little workaround with helper function but i seek some cleaner way.

    The problem is that i need replace value from mysql (0 or 1 this is such as “disabled” or “enabled”) .
    I try to do some magic with this piece of code:

    $this->datatables->select('id, name, enabled)->from('table');
    $this->datatables->edit_column('enabled', ('$2' == 1) ? 'image-enabled' :  'image-disabled' , 'id, enabled');
    echo $this->datatables->generate();

    but isn’t works good. Please, it is possible to achieve my needs with datatables?
    Many thanks for help.

  • #444 / Jul 24, 2014 11:23am

    hydride

    1 posts

    I’m using this library, but when I’m using GROUP_CONCAT() search is not working.

    $this->datatables->select('branches.id,branch_name,branch_address,latitude,longitude,district,phone,branch_email')
                ->unset_column('branches.id')
       ->from('branches')
                ->join('branch_services', 'branches.id = branch_services.bid', 'LEFT')
                ->join('services_avialable', 'services_avialable.id = branch_services.sid', 'LEFT')
                ->select('GROUP_CONCAT(services_avialable.service) as services')
                ->group_by('branches.id')
  • #445 / Jul 24, 2014 1:15pm

    CroNiX

    4713 posts

    Not sure about datatables, but with regular CI you’d use the 2nd parameter of select and set it to FALSE so CI doesn’t escape the table identifiers, which doesn’t work well using functions:

    ->select('GROUP_CONCAT(services_avialable.service) as services', FALSE)

    Not that it really matters as it’s code, but you spelled available wrong in services_avialable, which can make maintaining code hard, especially if someone else ever works on it.

  • #446 / Jul 28, 2014 12:29pm

    xcaleto

    1 posts

    Hi, thanks for this excelent library,  im using this library to generate datatables from DB data, but i want to get the ID from the DB table and add an id to each row ( each TR) in the table. I know how to use DT_RowId without Ignited datatables , but dont know how to use it with this library, any sugestion?

    Thanks and good code.

  • #447 / Aug 11, 2014 2:31pm

    pakistanihaider

    3 posts

    How to use join query using Ignited Datatables library??

  • #448 / Aug 21, 2014 6:42am

    pakistanihaider

    3 posts

    $this->datatables->select('FormID, FormName, FormPath, FormCIPath')
             ->unset_column('FormID')
             ->from('sys_forms');
         echo $this->datatables->generate();

    the above code can get me data, but it do not filter.

    i can see the filtering funcion in datatables in library.. but how to use it. i cant find the documentation for it.

    can any one plz help me with the functions in datatables.?


    i have grid and data is loading just fine but the search is not working..

  • #449 / Sep 07, 2014 10:27pm

    Johan N.

    6 posts

    ...Here is adapted for work with PostgreSQL library…

    Where? Please?

  • #450 / Sep 27, 2014 3:31am

    hirens

    1 posts

    Hi,
    I am new to this Datatable library. While trying to use this library it returns me the entire result set instead of the subset of records. Can anyone please guide me on how to use it.

    I am using CI version 2.2, datatable js version 1.10.2 and Datatable CI library version is 2.0 beta.

    Thanks,
    Hiren

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases