ERROR: oSettings is null
ERROR: oSettings is null
jorgevima74
Posts: 32Questions: 0Answers: 0
Hi all!!!
I'm rookie with DataTables and I have a problem that I think is very simple, but I can't solve :(
The error is "oSettings is null" and that's my 'datatable' code:
oTable = $('#tablatareas').dataTable( {
"sPaginationType": "full_numbers",
"aaSorting": [ ],
"aoColumns": [{"sTitle":"Referencia"},{"sTitle":"Planificaci
I'm rookie with DataTables and I have a problem that I think is very simple, but I can't solve :(
The error is "oSettings is null" and that's my 'datatable' code:
oTable = $('#tablatareas').dataTable( {
"sPaginationType": "full_numbers",
"aaSorting": [ ],
"aoColumns": [{"sTitle":"Referencia"},{"sTitle":"Planificaci
This discussion has been closed.
Replies
It looks like you are using server-side processing ("bServerSide": true) but you haven't told it the address from where to get the server-side data! This is done using the sAjaxSource variable. See the server-side processing demo: http://datatables.net/1.5-beta/examples/data_sources/server_side.html
Hope this helps!
Allan
I've tested your solution taking off ("bServerSide": true) but I'm still getting oSettings errors when I execute oTable.fnDraw();
I've modified the initialation of datatable:
oTable = $('#tablatareas').dataTable( {
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"sPaginationType": "full_numbers",
"aaSorting": [ [1,'desc'], [2,'asc'] ],
"oLanguage": {
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar _MENU_ registros",
"sZeroRecords": "No hay resultados",
"sInfo": "De la _START_ a la _END_, de _TOTAL_ registros",
"sInfoEmpty": "De la 0 a la 0 de 0 registros",
"sInfoFiltered": "(filtrado de _MAX_ registros totales)",
"sInfoPostFix": "",
"sSearch": "Buscar:",
"sUrl": "",
"oPaginate": {
"sFirst": "Primero",
"sPrevious": "Anterior",
"sNext": "Siguiente",
"sLast": "
One other thing to note is that you are setting a lot of parameters to their default value ("bAutoWidth" is true by default for example). This isn't needed - although it does no harm if you want to be verbose.
Allan
And I've taken off the defaults values to not repeat them.
Jorge.
I'm trying to redraw the table after insert a row (oTable.fnAddData) but it never redraw:
$.post('../editable_plans.php', {Id:f.IdHide,referencia:f.referencia,planif:f.planif,entrega:f.entrega,comments:f.comments,accion:'nuevo'}, function(data){
oTable.fnAddData( [
f.referencia,
f.planif,
f.entrega,
f.comments,
"Borrar" ] );
oTable.fnDraw();
$.prompt(data+" ("+f.IdHide+")",{ buttons: { Aceptar: true } });
});
What's wrong now??? :'(
Jorge.
I take this opportunity to congratulate you for the Datatables API. It help us to develop rich web applications. Thank you very much.
Jorge.
fnAddData() should actually redraw the table for you automatically - see the example: http://datatables.net/examples/example_add_row.html . If this is not happening then three are three options off the top of my head:
1. The re-draw is causing the data to be added to a different page of the tables table and you'll need to use pagination to jump to the right page.
2. The fnAddData() function isn't being called (put an alert() alongside it to test)
3. The number of data columns you are passing to fnAddData() doesn't match what you are using for the table.
Regarding your section question about a loading image - bProcessing will display a loading message (and you can put an image in through the internationalisation parameters) when performing complex tasks (although not printing). I'm not quite sure what you mean by the use of $.prompt(), but yes, you could integrate a prompt into most DataTables operations.
Regards,
Allan
Regarding $.pronmpt(), my question was if it is possible the next?
$.prompt("");
But I think that isn't a good solution for my purpose.
Jorge.
Yes fnAddData() will redraw the table with your new information. However, if I understand correctly, you need to add an ID attribute to the created TR node - is that correct?
What you can do, if this is the case, is make use of the return from fnAddData(). This function will return an array of integers, which gives you the indexes in aoData where the rows have been added. So you could do something like:
var oSettings = oTable.fnSettings();
var aiAdded = oTable.fnAddData( [whatever] );
var nTr = oSettings.aoData[ aiAdded[0] ].nTr; // Note only gets the first added TR (a loop would be needed for more)
nTr.setAttribute('id', "new_row"+unique);
Does that help?
Regarding the $.prompt - I'm honestly not sure - I haven't used this (I presume it's provided by jQuery UI?). But then if you don't need it any more - never mind :-)
Allan
Thank you again Allan.
Jorge.
var anTds = nTr.getElementsByTagName('td');
Then you have an array of TD nodes :-). .childNodes etc will all work as well.
Allan
"sProcessing": ""
Te page shows the text "" instead of the image I want.
Jorge.
oSettings.nProcessing.appendChild( document.createTextNode( oSettings.oLanguage.sProcessing ) );
and replace it with:
oSettings.nProcessing.innerHTML = oSettings.oLanguage.sProcessing;
And that should do the trick for you :-)
Allan
Jorge.
Hope that answers your question satisfactorily,
Allan
I've got a very nice datatable but it load very slow. I create the datatable with data from a data base and there are a lot of rows. It's possible to show the first page while generating the others?
Jorge.
The only way to do this at the moment is to use server-side processing (i.e. one page at a time is rendered). The reason for this is that when loading all the data, DataTables makes no assuption about how the loaded data is sorted, so it needs to load all of the data before it can do it's own sort. So I think perhaps server-sie processing might be the way to go if you have a lot of rows.
Regards,
Allan
Jorge.
It shows want you need on the client-side and what it expects from the server. There is also an example server-side implementation.
This is an example URL of what is sent to the server: http://datatables.net/1.5-beta/examples/examples_support/server_processing.php?iColumns=5&sColumns=&iDisplayLength=10&iDisplayStart=0&sSearch=&bEscapeRegex=true&sSearch_0=&bEscapeRegex_0=true&sSearch_1=&bEscapeRegex_1=true&sSearch_2=&bEscapeRegex_2=true&sSearch_3=&bEscapeRegex_3=true&sSearch_4=&bEscapeRegex_4=true&iSortingCols=1&iSortCol_0=0&iSortDir_0=asc
Regards,
Allan
"bServerSide": true,
"sAjaxSource": "../examples_support/server_processing.php"
and my PHP file has to SELECT the datas I want and return them with this format:
{"iTotalRecords": 57, "iTotalDisplayRecords": 57, "aaData": [ ['Gecko','Firefox 1.0','Win 98+ / OSX.2+','1','A'],['Gecko','Firefox 1.5','Win 98+ / OSX.2+','1','A'],['Gecko','Firefox 2.0','Win 98+ / OSX.2+','1','A'],['Gecko','Firefox 3.0','Win 2k+ / OSX.3+','1','A'],['Gecko','Camino 1.0','OSX.2+','1','A'],['Gecko','Camino 1.5','OSX.3+','1','A'],['Gecko','Netscape 7.2','Win 95+ / Mac OS 8.6-9.2','1','A'],['Gecko','Netscape Browser 8','Win 98SE+','1','A'],['Gecko','Netscape Navigator 9','Win 98+ / OSX.2+','1','A'],['Gecko','Mozilla 1.0','Win 95+ / OSX.1+','1','A']] }
I'm rigth??? I this situation, how can I asign an 'id' to every TR and every TD???
Jorge.
In this situation to manipulate the TRs and TDs you can use the fnRowCallback ( http://datatables.net/usage#fnRowCallback ) function. This function is called for every row which is drawn, and you are given information about that row and it's node - so you can add your id in there.
Here is an example of row callback in action:
http://datatables.net/examples/example_row_callback.html
Allan
Referencia Planificaci
Thanks,
Allan
But the ordering is failing now. I've tried to define it in the datatable and directly into the query but then any row is printed.
Att.
Jorge.
If you are using server-side processing, then the ordering should only be done on the server-side (DataTables will not use it's built-in sorting). Did you have a look at the example PHP which shows how you can construct a query with ORDER BY? You need to map the column indexes to the column names in your database.
Allan
oTable=$('#tablatareas').dataTable( {
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"sPaginationType": "full_numbers",
"aoColumns": [
{"sTitle":"Id", "sClass": "center", "bVisible":false},
{"sTitle":"Referencia", "sClass": "center"},
{"sTitle":"Planificaci
Allan
In addition to my problems, how can I get the {"iTotalRecords": 296, "iTotalDisplayRecords": 296} from the server response??? That's possible???
These are the query and some datas from the server response:
SELECT Id,Referencia,FechaPlanificacion,FechaEntrega,Comentarios FROM aedp_planificaciones ORDER BY FechaEntrega ASC, FechaPlanificacion DESC
{"iTotalRecords": 296, "iTotalDisplayRecords": 296, "aaData": [ ['296','MID0904','2009/05/29','0000/00/00','Pendiente WPT de PRO','Borrar'],['295','CCT0905','2009/05/28','0000/00/00','Ampliaci
I'm still not seeing where the error might be I'm afraid... Do you have a link you can provide so I can see it in action. If you don't want to post the link publicly, you can send it direct to me: www.datatables.net/contact .
The json output looks fine, as does the PHP - so I guess I'm missing something on my read through. The only thing I'm wondering about is where is the "sLimit" variable on the SQL query...
> In addition to my problems, how can I get the {"iTotalRecords": 296, "iTotalDisplayRecords": 296} from the server response??? That's possible???
If you want to be able to access the json that the server sends, then you can do something like this: http://datatables.net/1.5-beta/examples/server_side/custom_vars.html , and deal with the variables in the callback function.
Allan
")??
Att.
Jorge.