aoSearchCols + aoColumns + fnDraw

aoSearchCols + aoColumns + fnDraw

RicardRicard Posts: 8Questions: 0Answers: 0
edited October 2011 in General
Hi Everyone,

I'm facing next situation:

1.- I've got one DataTable with ServerSide processing, all is ok.
2.- I've got 3 links buttons to change the DataTable source.
3.- I can change correctly oSettings.sAjaxSource and oSettings.aaSorting
4.- I can't modify aoSearchCols and aoColumns to display new DataTable.

I attach my easy code:

1.- DataTable creation (works correctly)
[code]
var oTable;
$(document).ready(function() {
oTable = $('#dt_final').dataTable( {
"aoSearchCols": [null,{ "sSearch": "criteria1"},{ "sSearch": "criteria2"},null],
"aoColumns": [null,null,{ "bVisible": false },{ "bVisible": false }],
"iDisplayLength": 30,
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td', nRow).addClass('nowrap');
return nRow;
},
"bProcessing": true,
"bServerSide": true,
"bAutoWidth": false,
"sAjaxSource": "datatables/final_datatable.php",
"aaSorting": [[ 0, "asc" ]]
} );

jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages = 5;
} );
[/code]

2.- Links code (works correctly)
[code]
table 1
table 2
[/code]

3.- Redraw new DataTables (work correctly)
[code]
function getNewTable(id) {
if (id == 1) {
var oSettings = oTable.fnSettings();
oSettings.sAjaxSource = "datatables/final_datatables.php";
oSettings.aaSorting = [[ 0, "asc" ]];
oTable.fnDraw();
} else if (id == 2) {
var oSettings = oTable.fnSettings();
oSettings.sAjaxSource = "datatables/another_datatables.php";
oSettings.aaSorting = [[ 2, "desc" ]];
oTable.fnDraw();
}
}
[/code]

4.- Here I've got the problems. I've got a js error: d[b] is null at jquery.dataTables.min.js (line 91)
[code]
function getNewTable(id) {
if (id == 1) {
var oSettings = oTable.fnSettings();
oSettings.sAjaxSource = "datatables/final_datatables.php";
oSettings.aaSorting = [[ 0, "asc" ]];
oSettings.aoSearchCols = [null,{ "sSearch": "criteria1"},{ "sSearch": "criteria2"},null];
oSettings.aoColumns = [{ "bVisible": true },{ "bVisible": true },{ "bVisible": false },{ "bVisible": false }];
oTable.fnDraw();
} else if (id == 2) {
var oSettings = oTable.fnSettings();
oSettings.sAjaxSource = "datatables/another_datatables.php";
oSettings.aaSorting = [[ 2, "desc" ]];
oSettings.aoColumns = [{ "bVisible": true },{ "bVisible": true },{ "bVisible": true },{ "bVisible": false }];
oSettings.aoSearchCols = [null,{ "sSearch": "criteria1"},null,null];
oTable.fnDraw();
}
}
[/code]

I've been reading documentation and forums during 3 days and I'm unable to find the problem.
Is it correctly initialised the aoColumns and aoSearchCols?

Thanks in advance
Ricard

Replies

  • OmnimikeOmnimike Posts: 22Questions: 0Answers: 0
    Can I suggest that when you are developing you use jquery.dataTables.js instead of jquery.dataTables.min.js. That way when something in datatables goes wrong you can see what it's trying to do which caused it to break. The datatables code is pretty easy to read, though it does provide rather useless error messages if you use it wrong.

    If you use the non-minified version of datatables, what error does it give you then?
This discussion has been closed.