Home different function and variable on single Datatable
Reply: 0

different function and variable on single Datatable

user1674 Published in May 27, 2018, 3:34 am

a little help please.

I am using datatables in my wordpress project and I need to do two different functions and required different variable. The first function is to add index/rank in the first column, and the second one is to filter the active content of the second column. But datatables plugin wont allow it and will send an alert message.

The error is triggered by passing in options to a DataTables constructor object when the DataTable instance for the selected node has already been initialised.

Can someone show me how to do this? any help will be much appreciated

Currently, Here's my Code:

$(document).ready(function() {
    var t = $('#dt').DataTable( {
        "columnDefs": [ {
            "searchable": false,
            "orderable": false,
            "targets": 0
        } ],
        "order": [[ 7, "desc" ]],
    } );

    t.on( 'order.dt search.dt', function () {
        t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
            cell.innerHTML = i+1;
        } );
    } ).draw();
} );

$(document).ready(function() {
  otable = $('#dt').dataTable({
    "bSortCellsTop": true,
    "order": [[ 7, "desc" ]],

function filterme() {
  //build a regex filter string with an or(|) condition
  var types = $('input:checkbox[name="Category"]:checked').map(function() {
    return '^' + this.value + '\$';
  otable.fnFilter(types, 1, true, false, false, false);

  //use radio values
  var frees = $('input:radio[name="free"]:checked')[0].value;
  otable.fnFilter(frees, 2, false, false, false, false);

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305635 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO