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

[eluser]Unknown[/eluser]
I follow tutorial igneted datatables https://github.com/IgnitedDatatables/Ign...-Reference

Code:
function datatables(){
    $this->datatables
            ->select('TerminalID,AtmLocation,MaxNumOfBills1,MaxNumOfBills2')
            ->from('terminalset');
    header('Content-Type: application/json');
    echo $this->datatables->generate();
    }

and I have trouble when i use stored procedures.. like this

Code:
$this->db->query('proc_request "$parameter"');

how to call store procedure sql server in Igneted Datatables?

how do I add a query function in libraries datatables.php? https://github.com/IgnitedDatatables/Ign...tables.php

[eluser]rogertcd[/eluser]
Hi, I'm working with Ignited datatables and I have two custom columns, one of them is for options (Edit, delete); another is for add more information about the record, this information is extracted from another request to Data Base, I did it with a helper. However, when the final user write something in search field, the datatable doesn't search in that custom column, my code is:

CONTROLLER
Code:
$this->datatables->select("ID_F,CODIGO,SUSCRIPCION,NUMERO,NOMBRE,INSTITUCION1,FECHA_INS,FECHA_UPD")
                    ->add_column('INSTITUCION 2', '<span>$1</span>','get_institucion(ID_F)')
                    ->add_column('OPCIONES', get_buttons('$1'),'ID_F')
                    ->from('LISTAR_CONVENIOS');
                }
            }
            echo $this->datatables->generate();

HELPER
Code:
function get_institucion($id)
{
    $CI =& get_instance();
    $instituciones='';
    $CI->load->model('Convenios');
    $registros=$CI->Convenios->m_listar_parte2($id);
    foreach($registros->result() as $registro){
        if($instituciones!='') $instituciones.=', '.$registro->INSTITUCION;
        else $instituciones=$registro->INSTITUCION;
    }  
    return $instituciones;
}

I would like datatable takes in count "INSTITUCION 2" column, when the final user wants to search, Could someone help me please?

[eluser]rogertcd[/eluser]
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:
Code:
$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:
Code:
$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();

[eluser]Hayezb[/eluser]
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:

Code:
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="view_inventory/inventory_info/$1">view</a>', 'ID');
  
  echo $this->datatables->generate();
  
}

View:

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

I'm getting a POST 500 Internal Server Error.

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

Code:
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();
    }

[eluser]Unknown[/eluser]

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:

Code:
->edit_column('releve_statut', '$1', $this->label_this("releve_statut"))

Code:
public function label_this($str) {
        /**/
          if($str == "Réalisé"){
          $r =  'AAA';
          } else if ($str == "En cours"){
          $r = 'BBB';
          } else {
          $r = 'Error';
          }
          /* */
        return $r;
    }

[eluser]onlyjf[/eluser]
[quote author="Hayezb" date="1390919489"]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:

Code:
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="view_inventory/inventory_info/$1">view</a>', 'ID');
  
  echo $this->datatables->generate();
  
}

View:

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

I'm getting a POST 500 Internal Server Error. [/quote]



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

Code:
'fnServerData': function (sSource, aoData, fnCallback) {
                // ajax post csrf send.
                 var csrf = {"name": "&lt;?php echo $this->security->get_csrf_token_name(); ?&gt;", "value":$.cookie('&lt;?php echo $this->config->item("csrf_cookie_name"); ?&gt;')};
                 aoData.push(csrf);
        
                $.ajax
                ({
                    'dataType': 'json',
                    'type': 'POST',
                    'url': sSource,
                    'data': aoData,
                    'success': fnCallback
                });
            }

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

[eluser]Unknown[/eluser]
Hi,
Am having a problem with displaying data onto the table. The model return a well formatted json but i get an error:
Code:
DataTables warning (table id = 'my_id'): Requested unknown parameter '0' from the data source for row 0

my model:
Code:
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:
Code:
$(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:
Code:
<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?

[eluser]trta911[/eluser]
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:

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.




Theme © iAndrew 2016 - Forum software by © MyBB