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

[eluser]ηυмвєяσηє[/eluser]
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 :
Code:
->where(' (length = "46" OR length = "47") ' ,NULL,FALSE)


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

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

[eluser]ZaLiTHkA[/eluser]
[quote author="ninjayan" date="1350639894"]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
[/quote]
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.

[eluser]ninjayan[/eluser]
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?

[eluser]ninjayan[/eluser]
I have this current code.
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

[eluser]ZaLiTHkA[/eluser]
[quote author="ninjayan" date="1350735874"]I have this current code.
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[/quote]

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:
Code:
// 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:
Code:
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.

[eluser]ninjayan[/eluser]
Thanks for replying.
My code is only at the controller. I haven't tried yet to put it on my model.

[eluser]ninjayan[/eluser]
Ok, I think I have to show you the codes.

controller
Code:
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:
Code:
[removed]
$(document).ready(function() {
  $('#users_table').dataTable({
   //"sScrollX": "100%",
   //"sScrollXInner": "100%",
   "sPaginationType": "full_numbers",
   "bProcessing": true,
   "bServerSide": true,
   "bJQueryUI": true,
   "bDeferRender": true,
   "sAjaxSource": "&lt;?php echo base_url(); ?&gt;/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.

[eluser]ZaLiTHkA[/eluser]
[quote author="ninjayan" date="1350788692"]I want to add a column Action after the 'Date Registered'. Content of it will be icon disable user, promote/remove as admin.[/quote]
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. (:




Theme © iAndrew 2016 - Forum software by © MyBB