EllisLab text mark
Advanced Search
27 of 28
27
   
Ignited DataTables
Posted: 16 November 2012 12:36 AM   [ Ignore ]   [ # 401 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
71 posts

Hello. My ignited datatables code get the name and days and $1 is the name.

"<form id='edit_form' method='post' action='settings/edit_transaction_type/$1' class='left'>
      <input type='hidden' value='$1' id='trans_type' name='trans_type' readonly /> 

I want also to store the days on another hidden field. How would that be possible? thanks!

 
Posted: 11 December 2012 10:52 PM   [ Ignore ]   [ # 402 ]   [ Rating: 0 ]
Avatar
Joined: 2010-07-15
90 posts
ninjayan - 31 October 2012 03:49 AM

Hello it’s me again. My ignited datatables are now working and I added a column for delete action.

controller

public function get_transaction_types()
 
{
  $this
->load->library('datatables');
  
$this->datatables
     
->select('name, days'FALSE)
     ->
from('transaction_types')
     ->
add_column("Actions",
      
"<form id='edit_form' method='post' action='settings/edit_transaction_type/$1' class='left'>
      <input type='hidden' value='$1' id='trans_type' name='trans_type' readonly />
      <button class='settings-action-btn' title='Update'>
      <img src='assets/images/icons/edit.png' alt='Update' />
      </button>
      </form>
      <form id='delete_transaction_type_form' method='post' action='settings/delete_transaction_type/$1' method='post' class='right'>
      <input type='hidden' value='$1' id='delete_trans_type' name='delete_trans_type' readonly />
      <button class='settings-action-btn' title='Delete'>
      <img src='assets/images/icons/delete.png' alt='Delete' />
      </button>
      </form>"
,
      
"name");
  echo 
$this->datatables->generate();
 

view

<div id="transaction_type_table_container">
        <
table id="transaction_type_table" class="tight">
         <
thead>
          <
tr>
           <
th class="text-center">Transaction Type</th>
           <
th class="width160 text-center">Number of days</th>
           <
th class="width70 text-center">Action</th>
          </
tr>
         </
thead>
         <
tbody>
          <
tr>
           <
td colspan="7" class="dataTables_empty">Loading data from server</td>
          </
tr>
         </
tbody>
        </
table>
       </
div

My problem is I want to have a popup box (confimation box) when I click the delete button in action column. I try to add jquery on click to the button=‘settings-action-btn’ to alert but nothing happens. Any suggestion?

try attaching an onclick event to your button:

onclick='if(confirm("Are you sure?")) document.forms["delete_transaction_type_form"].submit(); return false;' 
 Signature 

Ignited Datatables

 
Posted: 01 January 2013 03:07 PM   [ Ignore ]   [ # 403 ]   [ Rating: 0 ]
Joined: 2013-01-01
1 posts
function view_user()
 
{
  $status
=1;
  
$this->datatables
    
->select("id,name,email,username,type,date_added")
    ->
from('ap_users'
    ->
unset_column('id')
    ->
edit_column('type''$1''callback_str_replace(1, ,type)')
    ->
edit_column('date_added''$1''callback_datechange(d-m-Y H:i|date_added)')
    ->
add_column('edit''<a href="profiles/edit/$1">edit</a>&nbsp;|&nbsp;<a href="profiles/edit/$1">delete</a>''id');
  echo 
$this->datatables->generate();             
  
 
}
The callback 
function not working it print full function in column.

javascript call

$('table.all').dataTable({
  
"bProcessing"true,
        
"bServerSide"true,
        
"sAjaxSource"config.base_url "main/view_user",
  
'fnServerData': function(sSourceaoDatafnCallback)
            
{
              
$.ajax
              
({
                
'dataType''json',
                
'type'    'POST',
                
'url'     sSource,
                
'data'    aoData,
                
'success' fnCallback
              }
);
            
}
  
    }
); 

Also can anyone help me where to write the callback function

Image Attachments
cidatatable.jpg
 
Posted: 04 January 2013 03:31 AM   [ Ignore ]   [ # 404 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
71 posts

there’s a problem on the code?
please see the attached screenshot..thank you.. smirk

Image Attachments
aa.png
 
Posted: 07 January 2013 06:38 AM   [ Ignore ]   [ # 405 ]   [ Rating: 0 ]
Joined: 2013-01-07
1 posts

Hello,

i have 2 table. “category” and “post”. category has 2 field : categoryId and categoryName. post has 3 field: postId, title, categoryId

now i want to show datatable categoryName and number of post according to this category.

how can i show this.

Regards,
Rejuan

 
Posted: 18 January 2013 02:25 AM   [ Ignore ]   [ # 406 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
71 posts

I’m using this code to order the datetime

"aaSorting"[[2"desc"]] 

Now I want to order datetime on query and this is my code

$this->load->library('datatables');
  
$this->datatables
     
->select("user_id, details, datetime")
                                        ->
order_by("datetime""desc")
     ->
from("logs");
  echo 
$this->datatables->generate(); 

but its not working.

 
Posted: 23 January 2013 09:09 AM   [ Ignore ]   [ # 407 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-20
753 posts

Are callbacks still available in v 0.7?

I’ve got

->edit_column('amount_paid''$1''callback_number_format(amount_paid|2)'); 

But it just renders that back to me in the datatable cell without processing it.

callback_number_format(amount_paid|2

Any ideas?

Thanks smile

 
Posted: 30 January 2013 04:50 AM   [ Ignore ]   [ # 408 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
71 posts

Hello.

How can I refresh the table after I delete a data?
the code is at the controller using the onclick.

When adding data, I use the fnDraw to refresh the table.

 
Posted: 02 February 2013 02:46 PM   [ Ignore ]   [ # 409 ]   [ Rating: 0 ]
Joined: 2013-02-02
4 posts

Anyone has implemented it with HTML Form?
I has a Form and the Table on the same page, and I wanted to use the form to Filtering data from SQL and when I press Submit, it refresh with the Table updated.

My Model “List.php” :

function number_list($startdate$enddate$number)
 
{
  $this
->load->library('datatables');

  
$this->datatables
   
->select('date, number, status')
   ->
from('trans')
   ->
where('date >='$startdate)
   ->
where('date <='$enddate)
   ->
where('number'$number);

  return 
$this->datatables->generate();
 

My Controller :

function get_result()
 
{
  $this
->load->model('list','',TRUE);

  
$startdate $this->input->post('range1');
  
$enddate $this->input->post('range2');
  
$number $this->input->post('number');

  echo 
$this->list->number_list($startdate$enddate$number);
 

I’m stuck to update it to the DataTables using the POST Ajax.
I have no idea to figure it out, any help will be appreciated.

Thanks :D

 
Posted: 02 February 2013 04:34 PM   [ Ignore ]   [ # 410 ]   [ Rating: 0 ]
Avatar
Joined: 2011-03-26
109 posts

@johnwbaxter

yup.. now without “callback_” prefix and “|” seperator..

->edit_column('amount_paid''$1''number_format("amount_paid","2")'); 

or

->edit_column('amount_paid''$1''number_format(amount_paid,2)'); 

this should work..

 Signature 

Ignited Datatables
Nested Sets

 
Posted: 04 February 2013 05:21 AM   [ Ignore ]   [ # 411 ]   [ Rating: 0 ]
Joined: 2013-02-02
4 posts

anyone?
help me, please. smile

thanks

 
Posted: 05 February 2013 11:42 AM   [ Ignore ]   [ # 412 ]   [ Rating: 0 ]
Joined: 2013-02-02
4 posts

Hello.

I googling and found thing that I need, but after using the code, my table not rendered completely.
My Table Code :

[removed]
 
$(document).ready(function() {
  oTable 
= $('#transaksiAJAX').dataTable({
   
"bJQueryUI"true,
   
"sPaginationType""full_numbers",
   
"bFilter"false,
   
"bSort"false,
   
"bProcessing"true,
   
"bServerSide"true,
   
"sAjaxSource""<?=base_url()?>member/get_result"
   "fnServerData"
: function(sSourceaoDatafnCallback{
    oTable
.push("name""range1""value": $( "#range1" ).val() },
       
"name""range2""value": $( "#range2" ).val() },
       
"name""nomer""value": $( "#nomer" ).val() );
    $.
ajax(
    
{
     
'dataType''json',
     
'type'    'POST',
     
'url'     sSource,
     
'data'    aoData,
     
'success' fnCallback
    }
);
   
}
  }
);
 
);
[removed] 

What’s wrong with the code?

thanks

 
Posted: 14 February 2013 02:34 PM   [ Ignore ]   [ # 413 ]   [ Rating: 0 ]
Avatar
Joined: 2011-03-26
109 posts

“sAjaxSource”: “<?=base_url()?>member/get_result”
“fnServerData”: function(sSource, aoData, fnCallback) {


there are no commas between those lines.

 Signature 

Ignited Datatables
Nested Sets

 
Posted: 17 February 2013 11:19 AM   [ Ignore ]   [ # 414 ]   [ Rating: 0 ]
Joined: 2013-02-02
4 posts

Thanks! It’s working now smile

 
Posted: 17 March 2013 02:40 PM   [ Ignore ]   [ # 415 ]   [ Rating: 0 ]
Joined: 2012-12-18
14 posts

Hi everyone,

First of all, thanks for this implementaition, I love the idea of having a library for doing datatables. This is a great tool which make everything easier.

I spent all the day trying to make it work without succes and this is honestly making me a bit crazy.

I have read the whole post on this forum, and a lot of documentation on the official website of datatables plugin, I’ve found a lot of examples, but nothing working for me.

I have implemented a very simple example.

Here is the code :

My view : datatables.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<
html>
 <
head>
  <
meta http-equiv="content-type" c charset=utf-8" />  
  <title>DataTables example</title>
<link rel="
stylesheet" href="<?php echo base_url(); ?>public/css/demo_page.css" type="text/css" media="screen" />
  <link rel="
stylesheet" href="<?php echo base_url(); ?>public/css/demo_table.css" type="text/css" media="screen" />
  [script src="
//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"][/script]
  
[script src="<?php echo base_url(); ?>public/js/jquery.dataTables.min.js"][/script]
 
</head>
 <
body>  
  <
div  id="dt_example">
   <
table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <
thead>
     <
tr>
      <
th width="20%">Id</th>
      <
th width="25%">Name</th>
      <
th width="25%">Description</th>
     </
tr>
    </
thead>
    <
tbody>
     <
tr>
      <
td colspan="5" class="dataTables_empty">Loading data from server</td>
     </
tr>
    </
tbody>
    <
tfoot>
     <
tr>
      <
th>Id</th>
      <
th>Name</th>
      <
th>Description</th>
     </
tr>
    </
tfoot>
   </
table>
  </
div>
  
[script]
   
$(document).ready(function() {
     
$('#example').dataTable{
         
"bProcessing"true,
         
"bServerSide"true,
         
"sAjaxSource""<?=base_url()?>datatables/get_list"
     
});
 
});
  
[/script]
 
</body>
</
html

My controller :

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Datatables extends CI_Controller
{
 
function __construct()
 
{
  parent
::__construct();
 
}

 
public function index()
 
{
  $this
->load->view('datatables');
 
}
 
 
function get_list()
 
{
  $this
->load->model('datatables','',TRUE);
  
  echo 
$this->datatables->list_all();
 
}

My Model :

<?php
class Datatables extends CI_Model {

 
 
function __construct()
    
{
        
// Call the Model constructor
        
parent::__construct();
    
}
    
    
function list_all()
 
{
  $this
->load->library('datatables');
  
  
$this->datatables
       
->select('id, name, description')
       ->
from('groups');
  
  return 
$this->datatables->generate();
 
}


The problem is when, I’m lauching the example like this : http://poplidays/datatables

I have the table empty, with the message “Processing”. Looking into Firebug gave me a 500 Internal Server Error on this GET request :

http://poplidays/datatables/get_list?sEcho=1&iColumns=3&sColumns;=&iDisplayStart=0&iDisplayLength=10&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&sSearch;=&bRegex=false&sSearch;_0=&bRegex_0=false&bSearchable_0=true&sSearch;_1=&bRegex_1=false&bSearchable_1=true&sSearch;_2=&bRegex_2=false&bSearchable_2=true&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&bSortable_1=true&bSortable_2=true&_=1363562912120

I have tried a lot of stuffs to make it work and each time I include the datatables library like this I have a 500 Internal Server Error


Would someone help me smile ?

Thanks a lot guys

 
27 of 28
27