Ignited DataTables
Posted: 14 June 2012 07:10 AM
[ Ignore ]
[ # 341 ]
[ Rating: 0 ]
Joined: 2011-04-19 7 posts
I did rewrite one of my datatables view with mDataProp function for almost all columns using “aoColumns”. At the end I discovered that sorting a columns doesn’t work because Ignited Code is receiving ‘function’ for mDataProp. Is is possible to redefine that ‘function’ type by returning something from one of a few type of calls to mDataProp function?
I don’t like a solution with “aoColumnDefs” because I had to use “aTargets” with column numbers. mDataProp object approach is much better for my complicated and composed columns.
Posted: 14 June 2012 11:36 AM
[ Ignore ]
[ # 342 ]
[ Rating: 0 ]
Joined: 2012-05-31 8 posts
virtualgadjo - 13 June 2012 10:51 AM
hi,
actually you should not echo anything in the controller but instead do something like this
$data[ 'result' ] = $this -> your_model -> your_function (); $this -> load -> view ( 'raw_ajax' , $data );
and then creat a view (raw_ajax.php in my example) with just
<?php echo $result ; ?>
it should work a little better
have swing
Hey thanks a lot for your reply.
I tryied what you suggested but still nothing displays if i set bServerSide: TRUE
If i set it to FALSE , everything works ok.
Posted: 15 June 2012 09:33 AM
[ Ignore ]
[ # 343 ]
[ Rating: 0 ]
Joined: 2011-04-19 7 posts
I converted two “mDataProp” columns from functions to ones as field names. Now Ignited Code makes a query with their names (field1 & field2) as filters:
WHERE (field1 LIKE ‘%’‘%’ OR field2 LIKE ‘%’‘%’ )
As there is no filter values the query returns no records instead of returning all records!?
Posted: 18 June 2012 12:15 PM
[ Ignore ]
[ # 344 ]
[ Rating: 0 ]
Joined: 2012-06-17 3 posts
echo prints result on the page as follows:
{“sEcho”:0,“iTotalRecords”:2,“iTotalDisplayRecords”:2,“aaData”:[[“1”,“23096720”,“MIHIR”,“mihir.parekh@abc.com”,“1”],[“2”,“12345”,“Mihir”,“abc@gmail.com”,“1”]],“sColumns”:“id,username,name,email,login_count”}
The table just displays processing…
My controller
function user_management_edit () { $this -> load -> library ( 'Datatables' ); $this -> datatables -> select ( 'id , username , name , email , login_count' ); $this -> datatables -> from ( 'user' ); echo $this -> datatables -> generate (); //$mytable = $this->datatables->generate(); //echo ($mytable); //$this->load->view('user_management_edit'); //$data['result'] = $this->datatables->generate(); $data[ 'main_content' ] = 'user_management_edit' ; $this -> load -> view ( 'Template' , $data ); }
My View
< section class= "grid_12" > < div class= "box" > < div class= "title" >< span class= "icon16_sprite i_spreadsheet" ></ span > Data table </ div > < p >< a href = "[removed]void(0);" > Click to add a new row </ a ></ p > < div class= "inside" > < table cellpadding = "0" cellspacing = "0" border = "0" class= "display" id = "test" > < thead > < tr > < th width = "10%" > Id </ th > < th width = "20%" > Username </ th > < th width = "25%" > Name </ th > < th width = "25%" > Email </ th > < th width = "20%" > Login Count </ th > </ tr > </ thead > < tbody > < tr > < td colspan = "5" class= "dataTables_empty" > Loading data from server </ td > </ tr > </ tbody > </ table > </ div > </ div > </ section >
My Template initializing script
[removed] $( document ). ready (function() { $( '#test' ). dataTable ( { "bProcessing" : true , "bServerSide" : true , "sServerMethod" : "POST" , "sPaginationType" : "full_numbers" , "bDeferRender" : true , "sAjaxSource" : "<?php echo base_url(); ?>index.php/home/user_management_edit" , "aoColumns" : [ { 'sName' : 'id' } , { 'sName' : 'username' } , { 'sName' : 'name' } , { 'sName' : 'email' } , { 'sName' : 'login_count' } ] , "fnServerData" : function ( sSource , aoData , fnCallback ) { $. ajax ( { "dataType" : "json" , "type" : "POST" , "url" : sSource , "data" : aoData , "success" : fnCallback , } ); } } ); } ); [removed]
Please help me solve this issue
Posted: 19 June 2012 05:43 AM
[ Ignore ]
[ # 345 ]
[ Rating: 0 ]
Joined: 2010-09-25 7 posts
concat is not working on select
select ( "id, CONCAT('first_name', ' ', 'last_name') as name" );
Posted: 19 June 2012 07:42 AM
[ Ignore ]
[ # 346 ]
[ Rating: 0 ]
Joined: 2012-02-15 4 posts
Hi!!
I have a problem with this useful library.
My situation as follows.
Datatables library in application/libraries
the view with the datatable table:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > < html > < head > < meta http - equiv = "content-type" content = "text/html; charset=utf-8" /> < link rel = "shortcut icon" type = "image/ico" href = "http://www.datatables.net/media/images/favicon.ico" /> < title > DataTables example </ title > < style type = "text/css" title = "currentStyle" > @ import "http://datatables.net/release-datatables/media/css/demo_page.css" ; @ import "http://datatables.net/release-datatables/media/css/demo_table.css" ; </ style > [removed][removed] [removed][removed] [removed] $( document ). ready (function() { $( '#example' ). dataTable ( { 'bServerSide' : true , 'sAjaxSource' : '<?=site_url("agents/ajax")?>' , } ); } ); [removed] </ head > < body id = "dt_example" > < div id = "container" > < h1 > Ignited Datatables </ h1 > < table border = "0" cellpadding = "4" cellspacing = "0" class= "display" id = "example" > < thead > < tr > < th width = "10%" > Name </ th > < th width = "10%" > Surname </ th > </ tr > </ thead > < tbody > < tr > < td > loading ...</ td > </ tr > </ tbody > </ table > </ div > </ body > </ html >
the function ajax() in controller “agents” that is called in datatable init
function ajax () { $this -> datatables -> select ( 'name, surname' ) -> from ( 'agents' ); echo $this -> datatables -> generate () ; }
The problem is that table rows does not show up.
if I access directly to the function ajax(), the output is:
{ "sEcho" : 0 , "iTotalRecords" : 5 , "iTotalDisplayRecords" : 5 , "aaData" : [[ "Piero" , "Maltesino" ] , [ "Piero" , "Maltese" ] , [ "piero" , "Maltese" ] , [ "prova" , "prova" ] , [ "Piero" , "Maltese" ]] , "sColumns" : "name,surname" }
that seems to be correct.
Firebug and chrome tools does not show any error.
If I use native php ignitedDatatable, it works correctly.
Any idea?
Thanks
Posted: 20 June 2012 04:03 AM
[ Ignore ]
[ # 347 ]
[ Rating: 0 ]
Joined: 2011-03-24 22 posts
hi,
@sport_billy
sorry to be a little late to answer…
may be you could try with ‘bProcessing’ set to true + “sServerMethod” : “POST”
then, as you’re using ajax source, you may need to add the function
'fnServerData' : function( sSource , aoData , fnCallback ) { $. ajax ( { 'dataType' : 'json' , 'type' : 'POST' , 'url' : sSource , 'data' : aoData , 'success' : fnCallback } ); }
last thing, be sure to change this
$sSearch = $this -> ci -> db -> escape ( $this -> ci -> input -> post ( 'sSearch' ));
into this
$sSearch = $this -> ci -> input -> post ( 'sSearch' );
line 290 in the librairy as the former line double escapes data and generates an sql syntax error (ci active record already escapes data)
have swing
Posted: 27 June 2012 08:00 AM
[ Ignore ]
[ # 348 ]
[ Rating: 0 ]
Joined: 2012-05-31 8 posts
virtualgadjo - 20 June 2012 04:03 AM
hi,
@sport_billy
sorry to be a little late to answer…
may be you could try with ‘bProcessing’ set to true + “sServerMethod” : “POST”
then, as you’re using ajax source, you may need to add the function
'fnServerData' : function( sSource , aoData , fnCallback ) { $. ajax ( { 'dataType' : 'json' , 'type' : 'POST' , 'url' : sSource , 'data' : aoData , 'success' : fnCallback } ); }
last thing, be sure to change this
$sSearch = $this -> ci -> db -> escape ( $this -> ci -> input -> post ( 'sSearch' ));
into this
$sSearch = $this -> ci -> input -> post ( 'sSearch' );
line 290 in the librairy as the former line double escapes data and generates an sql syntax error (ci active record already escapes data)
have swing
Hello and thanks again very much for your help..i made all of the changes you suggested but still nothing shows up if i set “bServerSide”: TRUE
Have you managed to make it work?
If so, can you please give me a sample of your code that works so i can test it?
Posted: 29 June 2012 02:53 AM
[ Ignore ]
[ # 349 ]
[ Rating: 0 ]
Joined: 2012-06-29 2 posts
where to download Datatables.php
Posted: 30 June 2012 08:36 AM
[ Ignore ]
[ # 351 ]
[ Rating: 0 ]
Joined: 2012-06-29 2 posts
hi
i am trying to do server side coding,
My Controller is
post.php
<?php
class post Extends CI_Controller{
function __construct()
{
parent::__construct();
}
function index() {
$this->load->view(‘main’);
}
function listener() {
$table = ‘post’;
$columns = array(‘title’, ‘category’, ‘post_date’,‘add_time’);
$index = ‘id’;
$this->load->library(‘Datatables’);
$data[‘result’] = $this->datatables->generate($table, $columns, $index);
echo $data[‘result’];
}
function test() {
$this->load->view(‘test’);
}
}
==========*********==========
and View is
test.php
[removed]
$(document).ready(function(){
$(’#test_table’).dataTable({
‘bServerSide’ : true,
‘bAutoWidth’ : false,
‘sPaginationType’: ‘full_numbers’,
‘sAjaxSource’: ‘post/listener’,
‘aoColumns’ : [
{ ‘sName’: ‘title’},
{ ‘sName’: ‘category’},
{ ‘sName’: ‘post_date’},
{ ‘sName’: ‘add_time’ },
],
‘fnServerData’: function(sSource, aoData, fnCallback){
$.ajax({
‘dataType’: ‘json’,
‘type’: ‘POST’,
‘url’: sSource,
‘data’: aoData,
‘success’: fnCallback
});
},
});
});
[removed]
<fieldset>
<legend>
Search Result
</legend>
<table cellpadding=“0” cellspacing=“0” border=“0” class=“display” id=‘test_table’>
<thead>
<tr class=“odd gradeX”>
<th>Title</th>
<th>Category</th>
<th>Post Date</th>
<th>Added Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>loading..</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Title</th>
<th>Category</th>
<th>Post Date</th>
<th>Added Date</th>
</tr>
</tfoot>
</table>
</fieldset>
=======*********=======
main.php
<html>
<head>
<link rel=“stylesheet” href=”<?php echo base_url()?>css/master.css”>
<link rel=“stylesheet” href=”<?php echo base_url()?>css/tables.css”>
<link rel=“stylesheet” href=”<?php echo base_url()?>css/iphone-check.css”>
<link rel=“stylesheet” href=”<?php echo base_url()?>css/icons.css”>
<link rel=“stylesheet” href=”<?php echo base_url()?>js/media/css/TableTools.css” type=“text/css” />
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed]
$(document).ready(function(){
//$.post(“http://localhost/dt_sample/index.php/post/test”,function(data){
$.post(‘post/test’, function(data){
$(’#target_area’).html(data);
});
});
[removed]
</head>
<body>
<div class=“navigation_button” id=‘test_button’>Test DataTable with CL Framework</div>
<div class=“content_area” id=“target_area”></div>
</body>
</html>
i am not getting the ouput… so any one can help me
Posted: 02 July 2012 10:03 AM
[ Ignore ]
[ # 352 ]
[ Rating: 0 ]
Joined: 2011-04-19 7 posts
phpstudent - 30 June 2012 08:36 AM
hi
i am trying to do server side coding,
My Controller is
post.php
....
i am not getting the ouput… so any one can help me
The best way to debug such errors is by using Firefox Firebug or Webkit development tools. There is a “Net” tab within which you can see what your server side function returns: either data or some html with errors.
Posted: 04 July 2012 10:49 PM
[ Ignore ]
[ # 353 ]
[ Rating: 0 ]
Joined: 2010-07-15 90 posts
phpstudent - 30 June 2012 08:36 AM
hi
i am trying to do server side coding,
My Controller is
post.php
<?php
class post Extends CI_Controller{
function __construct()
{
parent::__construct();
}
function index() {
$this->load->view(‘main’);
}
function listener() {
$table = ‘post’;
$columns = array(‘title’, ‘category’, ‘post_date’,‘add_time’);
$index = ‘id’;
$this->load->library(‘Datatables’);
$data[‘result’] = $this->datatables->generate($table, $columns, $index);
echo $data[‘result’];
}
function test() {
$this->load->view(‘test’);
}
}
==========*********==========
and View is
test.php
[removed]
$(document).ready(function(){
$(’#test_table’).dataTable({
‘bServerSide’ : true,
‘bAutoWidth’ : false,
‘sPaginationType’: ‘full_numbers’,
‘sAjaxSource’: ‘post/listener’,
‘aoColumns’ : [
{ ‘sName’: ‘title’},
{ ‘sName’: ‘category’},
{ ‘sName’: ‘post_date’},
{ ‘sName’: ‘add_time’ },
],
‘fnServerData’: function(sSource, aoData, fnCallback){
$.ajax({
‘dataType’: ‘json’,
‘type’: ‘POST’,
‘url’: sSource,
‘data’: aoData,
‘success’: fnCallback
});
},
});
});
[removed]
<fieldset>
<legend>
Search Result
</legend>
<table cellpadding=“0” cellspacing=“0” border=“0” class=“display” id=‘test_table’>
<thead>
<tr class=“odd gradeX”>
<th>Title</th>
<th>Category</th>
<th>Post Date</th>
<th>Added Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>loading..</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Title</th>
<th>Category</th>
<th>Post Date</th>
<th>Added Date</th>
</tr>
</tfoot>
</table>
</fieldset>
=======*********=======
main.php
<html>
<head>
<link rel=“stylesheet” href=”<?php echo base_url()?>css/master.css”>
<link rel=“stylesheet” href=”<?php echo base_url()?>css/tables.css”>
<link rel=“stylesheet” href=”<?php echo base_url()?>css/iphone-check.css”>
<link rel=“stylesheet” href=”<?php echo base_url()?>css/icons.css”>
<link rel=“stylesheet” href=”<?php echo base_url()?>js/media/css/TableTools.css” type=“text/css” />
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed]
$(document).ready(function(){
//$.post(“http://localhost/dt_sample/index.php/post/test”,function(data){
$.post(‘post/test’, function(data){
$(’#target_area’).html(data);
});
});
[removed]
</head>
<body>
<div class=“navigation_button” id=‘test_button’>Test DataTable with CL Framework</div>
<div class=“content_area” id=“target_area”></div>
</body>
</html>
i am not getting the ouput… so any one can help me
hi there, sorry for the late reply but the version of IgnitedDatatables you are using has long been outdated and is kind of deprecated. you may get the latest version on out github page at: https://github.com/IgnitedDatatables/Ignited-Datatables/ and consult the wiki section there for usage guide.
Signature
Ignited Datatables
Posted: 16 July 2012 03:47 AM
[ Ignore ]
[ # 354 ]
[ Rating: 0 ]
Joined: 2012-03-05 1 posts
Hi There,
I am using datatables in admin panel.
I had one issue with this.
Can you please tell me how to modify data before displaying it. or before passing it to the client as json data.
For Example: in my table created and modify date is there which i want to display in another format say total seconds to may be and GMT or human readable form,
Another Example: suppose i have path or name of the image into database table now i want to display it as image with img and a tag.
Can you please tell me how can i do this..
Thanks