Welcome Guest, Not a member yet? Register   Sign In
DataTables 1.10 > Library
#11

Yes, it is really handled through the DataTables JS library.  Here is an example of the `columns` option in the JavaScript setup for DataTables.


Code:
       columns: [
      {
        data: null,
        defaultContent: '<span class="btn btn-info btn-edit btn-xs">Edit</span> ',
           orderable: false,
           searchable: false
       },
           {   data: "st_name"  },
           { data: "st_address" },
           { data: "st_city" },
       { data: "st_state" },
       { data: "st_zip"  },
       
       { data: "st_phone" }
       ]


Then you can put a event listener on the button using jQuery:


Code:
    $("#storetable tbody").on("click", ".btn-edit", function() {
  var tr = $(this).closest("tr");
    var recordId = tr.attr("id");

//call some ajax to edit / delete record
// ....
   });


Make sure you specify the db column to map to the table row id in the Datatable CodeIgniter lib.


PHP Code:
$this -> load -> library('Datatable', array('model' => 'store_dt''rowIdCol' => 'store_no')); 

Here is the DataTable documentation for the options on the columns.
Reply


Messages In This Thread
DataTables 1.10 > Library - by zepernick - 01-09-2015, 12:20 PM
RE: DataTables 1.10 > Library - by Rufnex - 01-09-2015, 12:41 PM
RE: DataTables 1.10 > Library - by zepernick - 01-09-2015, 12:56 PM
RE: DataTables 1.10 > Library - by zepernick - 01-10-2015, 05:46 AM
RE: DataTables 1.10 > Library - by Rufnex - 01-10-2015, 08:31 AM
RE: DataTables 1.10 > Library - by zepernick - 01-12-2015, 07:07 AM
RE: DataTables 1.10 > Library - by GrigoreMihai - 02-03-2015, 08:11 AM
RE: DataTables 1.10 > Library - by zepernick - 02-03-2015, 06:44 PM
RE: DataTables 1.10 > Library - by marcelo - 02-03-2015, 09:25 AM
RE: DataTables 1.10 > Library - by yufieko - 04-13-2015, 05:25 AM
RE: DataTables 1.10 > Library - by zepernick - 04-13-2015, 07:13 AM
RE: DataTables 1.10 > Library - by kaederukawa7 - 05-17-2015, 10:05 PM
RE: DataTables 1.10 > Library - by kaederukawa7 - 05-17-2015, 10:08 PM
RE: DataTables 1.10 > Library - by RWCH - 03-10-2016, 07:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB