Do i really need td elements if sAjaxSource is used?
Do i really need td elements if sAjaxSource is used?
Hello there,
i want to use sAjaxSource. The json data is loaded from the server but my table is always empty, i only see the "Showing 1 to 2 of 2 entries" Message, the search box and the show entries combobox. Whats wrong here?
Do I really need to add tbody tr td by myself or should this be done by datatables.
Sorry for that question, but it seems a little bit strange to me that data is fetched from server but i need to add everything by myself... (if this is the case).
i want to use sAjaxSource. The json data is loaded from the server but my table is always empty, i only see the "Showing 1 to 2 of 2 entries" Message, the search box and the show entries combobox. Whats wrong here?
Do I really need to add tbody tr td by myself or should this be done by datatables.
Sorry for that question, but it seems a little bit strange to me that data is fetched from server but i need to add everything by myself... (if this is the case).
This discussion has been closed.
Replies
DataTables will do it for you if you don't give the table a tbody.
Can you use the debugger please ( http://debug.datatables.net ) so I can see what is in the table? Also a link would be useful.
Allan
i first want to describe what i want todo.
I create a json file on a server with this format:
[code]
{
"columns":["","Col1","Col2","Col3","Col4","Col5","Col6"],
"data":[
["1","Data1","Data2","Data3","Data4","Data5","Data6"]
]
}
[/code]
I use the following html/js to show the datatable:
[code]
jQuery(document).ready(function() {
jQuery('#result').dataTable({
'fnServerData': function( sSource, aoData, fnCallback )
{
jQuery.getJSON( sSource, aoData, function (json)
{
var _table = jQuery('#result');
var _data = processJsonReport(_table, json);
fnCallback(_data);
})
},
'bProcessing':true,
'sAjaxDataProp':'data',
'sAjaxSource':/path/to/json/file'
});
});
[/code]
The processJsonReport function does add the thead:
[code]
function processJsonReport(table,json)
{
table.empty();
var _tablecontent = "";
// append theads to the table
if (json.columns)
{
_tablecontent = "";
for(var _i=0; _i
> PS: The debugger seems not to want to play with me :(
It might not like the idea of the DataTable breaking halfway through the initialisation - which is what is happening since there are no columns initially.
Allan
[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
function processJsonReport(table,json)
{
table.empty();
var _tablecontent = "";
// append theads to the table
if (json.columns)
{
_tablecontent = "";
for(var _i=0; _i
Allan