2016-04-13 4 views
0

Für meine Webanwendung, iam mit jQuery Datentabelle mit Ajax, um Daten aus der Datenbank zu holen.Aktuell 'icheck' wird in jQuery Seite bereit Funktion initiiert.Was das Problem nach dem Aufrufen von Datentabelle oder Filter oder Suche passiert in Datentabelle, Daten richtig erhalten und icheck-Kontrollkästchen werden als normale Kontrollkästchen angezeigt. Wie kann ich den icheck Plugin-Aufruf innerhalb Datatable call.My-Code erinnern ist alsWie können wir ein anderes jQuery-Plugin innerhalb von jQuery Datatable-Aufrufergebnissen anstelle der Seitenbereitschaftsfunktion initiieren?

<table id="viewcat" class="table table-bordered table-striped mar-bottom0 mydatatable"> 
    <thead> 
    <tr> 
     <th style="width: 9%"><input type="checkbox" class="minimal" id="bulkDelete" /> <button type="submit" id="deleteTriger" name="submit" class="btn btn-primary btn-xs hor-align" value="Delete Selected" >Delete</button></th> 
     <th style="width: 2%">Sl.no</th> 
     <th style="width: 15%">Category Name</th>     
     <th style="width: 20%">Reference Links</th> 
     <th style="width: 25%">Image</th> 
     <th style="width: 15%"></th> 
     <th style="width: 10%"></th> 
    </tr> 
    </thead>     
</table> 

Script folgt, ist als

mir
<script> 
    $(function(){  
    $("#viewcat").DataTable({ 
     "fnRowCallback" : function(nRow, aData, iDisplayIndex){    
       $("td:nth-child(2)", nRow).append(aData[7]); 
       return nRow; 
      },  
     "processing": true, 
     "serverSide": true, 
     "order": [ 2, "asc" ], 
     "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 1, 4, 5 ,6] } ], 
     "ajax":{ 
      url :"maincategory/viewdata.php", // json datasource 
      type: "post",   
      error: function(){ 
      $(".viewcat-error").html(""); 
      $("#viewcat").append('<tbody class="viewcat-error"><tr><th colspan="7">No data found in the server</th></tr></tbody>'); 
      $("#viewcat_processing").css("display","none");   
      } 
     } 
    }); 

    }); 
</script> 

Bitte helfen folgt, es zu beheben ..

+0

Wo ist der Code für 'iCheck' Aktivierung? – itzmukeshy7

+0

+0

Setzen Sie '// iCheck für Checkbox- und Radioeingaben $ ('input [type =" checkbox "]. Minimal, Eingabe [type =" radio "]. Minimal'). ICheck ({checkboxClass: 'icheckbox_minimal-blue' , radioClass: 'iradio_minimal-blue'}); 'in' $ .ajax.success' nach dem Anhängen von Daten an die Tabelle; – itzmukeshy7

Antwort

0

Oh. . Endlich fand ich es .. Dies kann anderen helfen .. Eine API-Funktion anstelle von AJAX-Erfolg ist bereits da im Datatable-Plugin..Das ist "fnDrawCallback".

<script> 
    $(function(){  
    $("#viewcat").DataTable({ 
     "fnRowCallback" : function(nRow, aData, iDisplayIndex){    
       $("td:nth-child(2)", nRow).append(aData[7]); 
       return nRow; 
      }, 
     "fnDrawCallback": function(oSettings){ 
       $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({ 
        checkboxClass: 'icheckbox_minimal-blue', 
        radioClass: 'iradio_minimal-blue' 
       });},  
     "processing": true, 
     "serverSide": true, 
     "order": [ 2, "asc" ], 
     "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 1, 4, 5 ,6] } ], 
     "ajax":{ 
      url :"maincategory/viewdata.php", // json datasource 
      type: "post",   
      error: function(){ 
      $(".viewcat-error").html(""); 
      $("#viewcat").append('<tbody class="viewcat-error"><tr><th colspan="7">No data found in the server</th></tr></tbody>'); 
      $("#viewcat_processing").css("display","none");   
      } 
     } 
    }); 

    }); 
</script> 
Verwandte Themen