EllisLab text mark
Advanced Search
25 of 29
25
   
Ignited DataTables
Posted: 01 September 2012 02:16 AM   [ Ignore ]   [ # 371 ]   [ Rating: 0 ]
Avatar
Joined: 2012-07-19
32 posts
Dermis - 12 August 2012 12:50 AM

hi,

it has been a long time since i’m not update my CI, datatables and ignited data tables.

since i’ve updated to datatables 1.9.3 with latest ignited-datatables from github, my table did not shows any data.

my firebug console shows error :

TypeErroraData is undefined
for ( var i=0iLen=aData.length i<iLen i++ ) 

and my json returned

{"sEcho":1,"iTotalRecords":68,"iTotalDisplayRecords":0,"aaData":[],"sColumns":"uid"


im not sure what caused this error.

José Neto - 22 August 2012 07:16 PM

I’m having the same problem. Any answer?

I suspect this is a simple issue, in the JS where you initialize your datatable, try changing this line…

for ( var i=0iLen=aData.length i<iLen i++ ) 

...to this:

for ( var i=0iLen=aaData.length i<iLen i++ ) 

Your for loop is checking for the length of an array that doesn’t exist (notice the “aData.length” and “aaData.length”). Hope that helps. smile

 
Posted: 05 September 2012 01:51 PM   [ Ignore ]   [ # 372 ]   [ Rating: 0 ]
Joined: 2011-08-28
33 posts

my tables are not being populated, instead it throwing me this error

DataTables warning (table id = ‘student_table’): Requested unknown parameter ‘1’ from the data source for row 0

Below is my js code

script type="text/javascript" charset="utf-8">
$(
document).ready(function() {
    
$('#student_table').dataTable{
        
"bProcessing"true,
        
"bServerSide"true,
        
"sServerMethod""POST",
        
"sAjaxSource""<?php echo base_url()?>index.php/data/all"
    
);            
);
[removed] 

when i directly access index.php/data/all i get the below result

{"sEcho":0,"iTotalRecords":3,"iTotalDisplayRecords":3,"aaData":[["85","t1","1D"],["74","test475","4A"],["777","maiz","5"]],"sColumns":"id,name,class"

 

below is my html table

<table class="datatable tables" id="student_table">
                            <
thead>
                                <
tr>
                                        <
th>ID</th>
                                        <
th>Name</th>
                                        <
th>Class</th>
                                </
tr>
                            </
thead>
                            <
tbody>
                                <
tr>
                                    <
td class="dataTables_empty">Loading data from server</td>
                                                                    </
tr>
                            </
tbody>
                        </
table

and below is my model

$this->load->library('datatables');

    
$this->datatables->select('admission,name,class');
    
$this->datatables->from('students');
    echo 
$this->datatables->generate(); 

for almost 4 days im trying to solve this problem.. can some one please help me.. any help will be appreciated

 

 
Posted: 08 September 2012 04:17 PM   [ Ignore ]   [ # 373 ]   [ Rating: 0 ]
Joined: 2012-09-08
1 posts

livewirerules the fixed is in page 36.

 
Posted: 09 September 2012 06:11 PM   [ Ignore ]   [ # 374 ]   [ Rating: 0 ]
Joined: 2012-09-09
1 posts

I’m having problem with IgnitedDatatables-native-php-version.
I’m using MySQLi and getting this error:


Warning:  mysql_real_escape_string() [function.mysql-real-escape-string]: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2) in xxx/scripts/datatables/dataTables.ignition.php on line 64


Code responsiblke for that error:

protected function input($field$escape TRUE)
    
{
      
if(isset($_POST['sEcho']) && isset($_POST[$field]))
        return (
$escape == TRUE)? mysql_real_escape_string($_POST[$field]) : $_POST[$field];
      elseif(isset(
$_GET['sEcho']) && isset($_GET[$field]))
        return (
$escape == TRUE)? mysql_real_escape_string($_GET[$field]) : $_GET[$field];
      else
        return 
FALSE;
    

How to change this code to be compatible with mysqli ?

 
Posted: 12 September 2012 02:51 PM   [ Ignore ]   [ # 375 ]   [ Rating: 0 ]
Avatar
Joined: 2011-03-26
109 posts

hi solver,

i have just updated the native version of the library for that.. check it.

Regards..
Yusuf

 Signature 

Ignited Datatables
Nested Sets

 
Posted: 12 September 2012 05:26 PM   [ Ignore ]   [ # 376 ]   [ Rating: 0 ]
Avatar
Joined: 2011-03-26
109 posts

i didnt like the latest changes of the library so i decide to continue from my latest commit..

So here is what ive done for today,

- Added group_by and like functions
- renamed ‘add_columns’ and ‘edit_columns’ functions to ‘add’ and ‘edit’. it is way more simple.

https://github.com/n1crack/Ignited-Datatables

note: The latest official datatables also includes distinct and or_where functions. It doesnt fit those functions in this library.
If you want to use or_where function simply :

->where(' (length = "46" OR length = "47") ' ,NULL,FALSE

 Signature 

Ignited Datatables
Nested Sets

 
Posted: 17 September 2012 04:08 AM   [ Ignore ]   [ # 377 ]   [ Rating: 0 ]
Joined: 2012-09-17
1 posts

Hi all,

I have a problem with jquery datatables when I use group_by. The data loaded in the datatable are correct but records count shown in the footer of the datatable is bad. Can somebody help me with this?
Thanks

Matoo

 
Posted: 19 October 2012 05:44 AM   [ Ignore ]   [ # 378 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
77 posts

Totally new to this. I want to use on the application I am developing. This is a great library. Can someone give me a working example? Or just a tutorial link? I also want to add 1 column at the end for actions(select/delete) thanks

 
Posted: 19 October 2012 11:24 AM   [ Ignore ]   [ # 379 ]   [ Rating: 0 ]
Avatar
Joined: 2012-07-19
32 posts
ninjayan - 19 October 2012 05:44 AM

Totally new to this. I want to use on the application I am developing. This is a great library. Can someone give me a working example? Or just a tutorial link? I also want to add 1 column at the end for actions(select/delete) thanks

This CI library is built around the ‘server side’ data source as seen in this example. It doesn’t include DataTables itself. smile What you’re asking about is more a DT related question, to which I’m sure you’ll find all the info you need in documentation on DataTables.net.

 
Posted: 20 October 2012 02:23 AM   [ Ignore ]   [ # 380 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
77 posts

I have datatables working on plain php but now i want to use it in codeigniter. So I came over here and found this. If this is not what I’m looking for, can you give me links/tutorials/samples how to implement datatables in codeigniter?

 
Posted: 20 October 2012 08:24 AM   [ Ignore ]   [ # 381 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
77 posts

I have this current code.

$this->load->library('datatables');
  
$this->datatables
    
->select("username")
    ->
select("CONCAT(salutation, '. ', first_name, ' ', middle_initial, '. ', last_name) as full_name"FALSE)
    ->
select("office, position, email, privilege, datetime_registered")
    ->
where("username !="$this->session->userdata('username'))
    ->
from("users")
    ->
add_column('view''<a href="">AA</a>');
  echo 
$this->datatables->generate(); 

I want to add a column at the end for ‘Actions’
add_coumn is not working

 
Posted: 20 October 2012 02:42 PM   [ Ignore ]   [ # 382 ]   [ Rating: 0 ]
Avatar
Joined: 2012-07-19
32 posts
ninjayan - 20 October 2012 08:24 AM

I have this current code.

$this->load->library('datatables');
  
$this->datatables
    
->select("username")
    ->
select("CONCAT(salutation, '. ', first_name, ' ', middle_initial, '. ', last_name) as full_name"FALSE)
    ->
select("office, position, email, privilege, datetime_registered")
    ->
where("username !="$this->session->userdata('username'))
    ->
from("users")
    ->
add_column('view''<a href="">AA</a>');
  echo 
$this->datatables->generate(); 

I want to add a column at the end for ‘Actions’
add_coumn is not working

Ah, I see what you mean now. Sorry, I misunderstood your first post.. My mistake. smile

Just to confirm, is this code in your controller or your model? Is the data getting through if you try without the add_column() method in the chain?

If I remember correctly, when I tried this I only got it to work after using print() at the end of the $this->datatables() chain. Here’s the relevant code from a recent project I worked on:

// MY_Controller
function get_list() {
 $this
->load->model('my_model');
 
$this->my_model->get_list();
}

// MY_Model
public function get_list() {
 $this
->datatables->select('
  Table.Col1,
  Table.Col2,
  Table.Col3
 '
);
 
$this->datatables->from('Table');
 
 print(
$this->datatables->generate());

In this case, I set the AJAX source in my DT initialization to a url generated by:

echo(base_url('my_controller/get_list')); 

Not sure if there’s a better way to do this, but this worked for me. Just a thought, but maybe try use print() instead of echo() on your generate() line.

 
Posted: 20 October 2012 10:38 PM   [ Ignore ]   [ # 383 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
77 posts

Thanks for replying.
My code is only at the controller. I haven’t tried yet to put it on my model.

 
Posted: 20 October 2012 11:04 PM   [ Ignore ]   [ # 384 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
77 posts

Ok, I think I have to show you the codes.

controller

public function get_active_users() {
  $this
->load->library('datatables');
  
$this->datatables
    
->select("username")
    ->
select("CONCAT(salutation, '. ', first_name, ' ', middle_initial, '. ', last_name) as full_name"FALSE)
    ->
select("office, position, email, privilege, datetime_registered")
    ->
where("username !="$this->session->userdata('username'))
    ->
from("users")
    ->
add_column("view""<a>AA</a>");
  echo 
$this->datatables->generate();
 

view:

[removed]
 
$(document).ready(function() {
  
$('#users_table').dataTable({
   
//"sScrollX": "100%",
   //"sScrollXInner": "100%",
   
"sPaginationType""full_numbers",
   
"bProcessing"true,
   
"bServerSide"true,
   
"bJQueryUI"true,
   
"bDeferRender"true,
   
"sAjaxSource""<?php echo base_url(); ?>/users/get_active_users",
   
"sServerMethod""POST"
  
});
 
});
 
[removed]

<thead>
      <
tr>
       <
th class="width70 text-center">Username</th>
       <
th class="text-center">Full Name</th>
       <
th class="text-center">Office</th>
       <
th class="text-center">Position</th>
       <
th class="text-center">Email</th>
       <
th class="width60 text-center">Privilege</th>
       <
th class="width160 text-center">Date Registered</th>
      </
tr>
     </
thead>
     <
tbody>
      <
tr>
       <
td colspan="7" class="dataTables_empty">Loading data from server</td>
      </
tr>
     </
tbody

I want to add a column Action after the ‘Date Registered’. Content of it will be icon disable user, promote/remove as admin.

 
Posted: 21 October 2012 05:40 AM   [ Ignore ]   [ # 385 ]   [ Rating: 0 ]
Avatar
Joined: 2012-07-19
32 posts
ninjayan - 20 October 2012 11:04 PM

I want to add a column Action after the ‘Date Registered’. Content of it will be icon disable user, promote/remove as admin.

I suspect the biggest issue here is the fact that the number of columns between your data source (in your controller) and the number of columns in your end table (in your view), do not match. You’re trying to put data for 8 columns into a 7 column table. Out of curiosity, have you tried adding an extra column to your HTML table in your view? Sometimes the simplest solution works out best in the end.

Unfortunately though, DataTables itself doesn’t support dynamically adding columns, this question has been asked many times on the DT forum in the past. Digging through these questions again this morning, I found a link to a tutorial that looks like it does exactly what you’re asking for [link].

Otherwise, have you considered using something like the drill-down rows example, placing the ‘user specific functions’ in the row that shows up below the clicked row? This way, the data is added dynamically to the row before it’s displayed, and the row is destroyed after it’s hidden. It’s very easy to use and very efficient as well.

This is giving me ideas for another project I’m working on now.. Time to go play. (:

 
25 of 29
25