Datatable not rend JSON from server
Datatable not rend JSON from server
lastcow
Posts: 1Questions: 0Answers: 0
I have a json send from server like following:
[code]
[
{"user":{"firstname":null,"lastname":null,"mrn":null,"username":"zhangyiddt"}},
{"user":{"firstname":null,"lastname":null,"mrn":null,"username":"lastcow"}}
]
[/code]
and i have html as following (haml version):
%table.datatable#patientlist
%thead
%tr
%th
Patient first name
%th
Patient last name
%th
Username
%th
MR Number
this is basically with 4 column header.
and here is my js:
[code]
$('#patientlist').dataTable({
bProcessing: false,
sAjaxSource: '/administration/allpatiens.json',
//sAjaxDataProp: 'object'
aoColumns:[
{mDataProp:'firstname'},
{mDataProp: 'lastname'},
{mDataProp: 'username'},
{mDataProp: 'mrn'}
],
success: function(json){
},
sPaginationType: 'full_numbers',
sDom: '<"header-table"lf>rt<"footer-table"ip>',
oLanguage: { oPaginate: {
sFirst: '<',
sPrevious: '(',
sNext: ')',
sLast: '>'
}},
fnInitComplete: function(t){
var $table = $(t.nTable), $head = $table.prev();
$head.find('select').uniform();
$head.find('.dataTables_length label').wrapInnerTexts();
$head.find('.dataTables_filter label').wrapInnerTexts();
$head.find('input[type=text]').wrap('').parent().prepend('' + createIcon('magnifier') + '');
$table.find('.sorting, .sorting_asc, .sorting_desc').wrapInner($('')).find('.parentsort').append('');
}
});
[/code]
when I load the page, i can see json download from server, but table always showing 'loading...', is there any wrong with json format?
please help.
Thanks, :)
[code]
[
{"user":{"firstname":null,"lastname":null,"mrn":null,"username":"zhangyiddt"}},
{"user":{"firstname":null,"lastname":null,"mrn":null,"username":"lastcow"}}
]
[/code]
and i have html as following (haml version):
%table.datatable#patientlist
%thead
%tr
%th
Patient first name
%th
Patient last name
%th
Username
%th
MR Number
this is basically with 4 column header.
and here is my js:
[code]
$('#patientlist').dataTable({
bProcessing: false,
sAjaxSource: '/administration/allpatiens.json',
//sAjaxDataProp: 'object'
aoColumns:[
{mDataProp:'firstname'},
{mDataProp: 'lastname'},
{mDataProp: 'username'},
{mDataProp: 'mrn'}
],
success: function(json){
},
sPaginationType: 'full_numbers',
sDom: '<"header-table"lf>rt<"footer-table"ip>',
oLanguage: { oPaginate: {
sFirst: '<',
sPrevious: '(',
sNext: ')',
sLast: '>'
}},
fnInitComplete: function(t){
var $table = $(t.nTable), $head = $table.prev();
$head.find('select').uniform();
$head.find('.dataTables_length label').wrapInnerTexts();
$head.find('.dataTables_filter label').wrapInnerTexts();
$head.find('input[type=text]').wrap('').parent().prepend('' + createIcon('magnifier') + '');
$table.find('.sorting, .sorting_asc, .sorting_desc').wrapInner($('')).find('.parentsort').append('');
}
});
[/code]
when I load the page, i can see json download from server, but table always showing 'loading...', is there any wrong with json format?
please help.
Thanks, :)
This discussion has been closed.
Replies
http://www.datatables.net/usage/server-side
Allan