EllisLab text mark
Advanced Search
3 of 28
3
   
Ignited DataTables
Posted: 20 December 2010 10:50 PM   [ Ignore ]   [ # 41 ]   [ Rating: 0 ]
Avatar
Joined: 2010-07-15
90 posts
Si Jampank - 08 December 2010 05:28 PM

i mean how can this library using for CRUD application?in that libraries i found how it can add addtional column for delete or update. But how can i use it?anyone help me.. so many thanks

if you browsed through the code in the library, at around line 214, you’ll see something like this:

/*
  add additional columns here
  like adding a Delete Row control for example:

  $aaData[$row_key][] = '<a href="#">Delete Button</a>';
*/ 

mmmkaye?

 Signature 

Ignited Datatables

 
Posted: 13 January 2011 12:09 PM   [ Ignore ]   [ # 42 ]   [ Rating: 0 ]
Joined: 2011-01-13
8 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.

 
Posted: 14 January 2011 05:29 AM   [ Ignore ]   [ # 43 ]   [ Rating: 0 ]
Joined: 2011-01-14
7 posts

Hi,

Just began playing with DataTables and this tutorial was great except I cannot have a table with more than 4 columns. I have a table with 9 columns and I get the following error via [removed]

DataTables warning (table id = ‘drivers’): Added data (size 9) does not match known number of columns (4)

I checked via firebug and the POST has (iColumns 4) as one of the parameters. I figured this was done dynamically with an array count of the columns you pass to the library but obviously not. I have searched all over the application looking for where this has been set to (4) or if there is a bug stopping the count to work.

Hoping someone could shed some light on the problem

Thanks in advance.

 
Posted: 14 January 2011 05:36 AM   [ Ignore ]   [ # 44 ]   [ Rating: 0 ]
Joined: 2011-01-13
8 posts

Take a look in JS-code where you create DataTable. Please, notice the parameter “aoColumns”.

 
Posted: 14 January 2011 05:54 AM   [ Ignore ]   [ # 45 ]   [ Rating: 0 ]
Joined: 2011-01-14
7 posts

Hey thanks for the quick reply,

Yeah I have tried that, but all the JS looks fine it is doing a count for the aoColumns to create the iColumns param. I was hoping someone had a similar problem with this library to help narrow it down.

Cheers

 
Posted: 14 January 2011 05:56 AM   [ Ignore ]   [ # 46 ]   [ Rating: 0 ]
Joined: 2011-01-13
8 posts

Have you tried to remove the parameter? I’m 90% sure the problem is somewhere in JS.

 
Posted: 14 January 2011 07:24 AM   [ Ignore ]   [ # 47 ]   [ Rating: 0 ]
Joined: 2011-01-14
7 posts

I don’t think its a JS problem, I changed to the most up to date version of DataTables JS and still nothing, all the information is being passed to the view but DataTables can’t show it based on this column count.

If I change the AJAX type from post to get I don’t get the error but it still does not show the data, in both post and get the response has all the data! I don’t know if the php isn’t passing the right column count properly!

 
Posted: 14 January 2011 07:42 AM   [ Ignore ]   [ # 48 ]   [ Rating: 0 ]
Joined: 2011-01-13
8 posts

I see. It’s hard to say what is wrong without the code.

 
Posted: 14 January 2011 07:45 AM   [ Ignore ]   [ # 49 ]   [ Rating: 0 ]
Joined: 2011-01-14
7 posts

ok i’ll send my code. Quick question how to I wrap my code in a post?

 
Posted: 14 January 2011 07:48 AM   [ Ignore ]   [ # 50 ]   [ Rating: 0 ]
Joined: 2011-01-13
8 posts

Use CODE tag in square brackets or use Post Reply instead of Fast Reply.

 
Posted: 14 January 2011 07:52 AM   [ Ignore ]   [ # 51 ]   [ Rating: 0 ]
Joined: 2011-01-14
7 posts

Thanks for that.

Here is my view.

<html>
<
head>
<
title>Welcome to CodeIgniter</title>

<!--<
link type="text/css" rel="stylesheet" href="css/demo_table.css" />-->
<
link type="text/css" rel="stylesheet" href="<?php echo asset_url() ?>css/smoothness/jquery-ui-1.8.2.custom.css" />
<
link type="text/css" rel="stylesheet" href="<?php echo asset_url() ?>css/styles.css" />


[removed][removed]
[removed][removed]

</head>

<
body>

<
div id="dt_example">
  <
table id="drivers" class="display">
    <
thead>
      <
tr>
        <
th>ID</th>
        <
th>Name</th>
        <
th>Address</th>
        <
th>Town</th>
        <
th>Postcode</th>
        <
th>Phone</th>
        <
th>Email</th>
        <
th>Driver No.</th>
        <
th>Badge No.</th>
      </
tr>
    </
thead>
    <
tbody>
      <
tr>
        <
td>loading...</td>
      </
tr>
    </
tbody>
  </
table>
</
div>
[removed]
  
$(document).ready(function()
  
{
    
$('#drivers').dataTable
    
({
      
'bProcessing'    true,
      
'bServerSide'    true,
      
'bAutoWidth'     false,
      
'sPaginationType''full_numbers',
      
'sAjaxSource'    '<?=base_url();?>welcome/listener',
      
'aoColumns'      
      
[
        {
          
'bSearchable'false,
          
'bVisible'   false
        }
,
        
null,
        
null,
        
null
      ]
,
      
'fnServerData': function(sSourceaoDatafnCallback)
      
{
        
$.ajax
        
({
          
'dataType''json',
          
'type'    'POST',
          
'url'     sSource,
          
'data'    aoData,
          
'success' fnCallback
        }
);
      
}
    }
);
  
});
[removed]

</body>
</
html


My Controller

<?php

class Welcome extends Controller {

    
function Welcome()
    
{
        parent
::Controller();
        
$this->load->helper(array('html''text'));
                
$this->load->library('form_validation');        
    
}
    
    
function index()
    
{
        
/* $this->load->model('M_drivers');     
        $data['drivers'] = $this->M_drivers->getAll(); */
        
$this->load->view('welcome_message');
    
}
    
    
public function listener() 
    
{
        $table 
"drivers";
        
$columns = array("id""name""address""town""postcode""phone""email""driverNo""badgeNo");
        
$index "id";
        
$this->load->library("Datatables");
        echo 
$this->datatables->generate($table$columns$index);
    
}
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */ 
 
Posted: 14 January 2011 07:57 AM   [ Ignore ]   [ # 52 ]   [ Rating: 0 ]
Joined: 2011-01-13
8 posts

ok. Take a look at that piece of code.

'aoColumns'      
      
[
        {
          
'bSearchable'false,
          
'bVisible'   false
        }
,
        
null,
        
null,
        
null
      ] 

Please, notice that you defined here only 4 columns while your controller returns 9. Add 5 more null.

 
Posted: 14 January 2011 08:12 AM   [ Ignore ]   [ # 53 ]   [ Rating: 0 ]
Joined: 2011-01-14
7 posts

Works a treat Thank you, can’t believe I was being so blind to it LOL smile

 
Posted: 15 January 2011 01:07 PM   [ Ignore ]   [ # 54 ]   [ Rating: 0 ]
Avatar
Joined: 2010-07-15
90 posts

o yes do take note of the number of nulls or simply how you define aoColumms. keep in mind that they should reflect the same number of columns as what was defined in your controller.

I didn’t mention this in my guide as I was basing the assumption of complete or very good understanding of the datatables library beforehand.

 Signature 

Ignited Datatables

 
Posted: 16 February 2011 05:27 AM   [ Ignore ]   [ # 55 ]   [ Rating: 0 ]
Joined: 2009-01-03
6 posts

hi all, please help me….
i am newbie…

why the output of mine like this :

{“sEcho”:0,“iTotalRecords”:“57”,“iTotalDisplayRecords”:“57”,“aaData”:[[“Trident”,“Internet Explorer 4.0”,“Win 95+”,“4”,“X”],[“Trident”,“Internet Explorer 5.0”,“Win 95+”,“5”,“C”],[“Trident”,“Internet Explorer 5.5”,“Win 95+”,“5.5”,“A”],[“Trident”,“Internet Explorer 6”,“Win 98+”,“6”,“A”],[“Trident”,“Internet Explorer 7”,“Win XP SP2+”,“7”,“A”],[“Trident”,“AOL browser (AOL desktop)”,“Win XP”,“6”,“A”],[“Gecko”,“Firefox 1.0”,“Win 98+ \/ OSX.2+”,“1.7”,“A”],[“Gecko”,“Firefox 1.5”,“Win 98+ \/ OSX.2+”,“1.8”,“A”],[“Gecko”,“Firefox 2.0”,“Win 98+ \/ OSX.2+”,“1.8”,“A”],[“Gecko”,“Firefox 3.0”,“Win 2k+ \/ OSX.3+”,“1.9”,“A”]]}

it has right output, but the datatable doesnt work… why ?
what i must do?

 
3 of 28
3