Datatables warning: requested unknown parameter '0' for row '0'

Datatables warning: requested unknown parameter '0' for row '0'

marilena6marilena6 Posts: 1Questions: 1Answers: 0

Hello, I am a complete newbie to codeigniter and jquery, I've read or related topics possible solutions but i don't know how to implement them on my code.



<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/t/bs/dt-1.10.11/datatables.min.css"/> <script type="text/javascript" src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('select').chosen( { disable_search_threshold: 10, allow_single_deselect: true } ); $('#search_results tbody').empty(); var table = $('#search_results').DataTable(); $('#search_documents_form').on('submit', function(event){ event.preventDefault(); table.clear(); $.ajax({ method: 'POST', url: '<?php echo base_url($this->uri->uri_string())?>', data: { 'search_documents': '1', 'location': $('#location').val(), 'document_type': $('#document_type').val(), 'search_terms': $('#search_terms').val() } }).success(function(data){ var result = $.parseJSON(data); if(result.length > 0){ $('.total_results').empty(); $('.total_results').append(' - ' + result.length +' results'); $.each(result, function(data){ //$('#search_results tbody').append('<tr><td>'+this.branch_name+'</td><td>'+this.document_type+'</td><td>'+this.document_name+'</td><td>'+this.document_update_date+'</td><td>'+ this.document_expiry_date +'</td><td><a href="'+this.document_path+'" target="_blank"><span class="fa fa-arrow-down"></span></a></td></tr>'); table.row.add([ this.document_branch, this.document_type, this.document_name, this.document_update_date, this.document_expiry_date, '<a href="'+this.document_path+'" target="_blank"><span class="fa fa-arrow-down"></span></a>']).draw(); }); } else { $('#search_results tbody').empty(); $('.total_results').empty(); $('.total_results').append(); $('#search_results tbody').append('<tr><td colspan="6"><center><h3>No Results</h3></center></td></tr>'); } }); }); }); </script><div class="container"> <form class="form-horizontal" id="search_documents_form" action="<?php echo base_url($this->uri->uri_string());?>" method="POST"> <input type="hidden" name="search_documents" value="1"> <div class="col-lg-12"> <legend>Search Documents</legend> <div class="panel panel-primary"> <div class="panel-heading">Search Critera</div> <div class="panel-body"> <div class="row"> <div class="col-lg-6"> <!-- Select Basic --> <div class="form-group"> <label class="col-md-4 control-label" for="selectbasic">Location</label> <div class="col-md-8"> <select id="location" name="location" class="form-control"> <option></option> <?php foreach($branches as $branch_type => $branches_by_type){?> <optgroup label="<?php echo $branch_type?>"> <?php foreach($branches_by_type as $branch_name){?> <option value="<?php echo $branch_name['branch_index']?>"><?php echo $branch_name['branch_name']?></option> <?php }?> </optgroup> <?php }?> </select> </div> </div> </div> <div class="col-lg-6"> <!-- Select Basic --> <div class="form-group"> <label class="col-md-4 control-label" for="document_type">Document Type</label> <div class="col-md-8"> <select id="document_type" name="document_type" class="form-control"> <option></option> <?php foreach($document_types as $type){?> <option><?php echo ucfirst($type['document_type']);?></option> <?php }?> </select> </div> </div> </div> </div> <div class="row"> <div class="col-lg-6"> <!-- Text input--> <div class="form-group"> <label class="col-md-4 control-label" for="search_terms">Search Terms</label> <div class="col-md-8"> <input id="search_terms" name="search_terms" type="text" placeholder="Search Terms" class="form-control input-md"> </div> </div> </div> <div class="col-lg-6"> <div class="form-group"> <div class="col-md-8 col-md-offset-4"> <button type="submit" class="btn btn-primary pull-right"> Search </button> </div> </div> </div> </div> </div> </div> </form> </div> <div class="col-lg-12"> <div class="panel panel-default" style="margin-bottom: 75px;"> <div class="panel-heading">Search Results <span class="total_results"></span></div> <div class="panel-body"> <table class="table table-bordered table-hover table-striped" id="search_results"> <thead> <th style="width: 200px;">Branch</th> <th>Document Type</th> <th>Document Name</th> <th style="width: 75px;">Updated</th> <th>Expiry Date</th> <th style="width: 50px;">Action</th> </thead> <tbody> <tr> <td colspan="6"> <center><h3>Please enter search criteria</h3></center> </td> </tr> </tbody> </table> </div> </div> </div> ``` (views code)

PLEASE HELP!

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    I don't immediately see the issue from the code above. The only thing that stands out for me is the colspan, which you can't have in a DataTable tbody - but you are removing that before using the DataTable.

    I'd need a link to a page showing the issue to be able to offer any help.

    Allan

This discussion has been closed.