Newbie question - Datatables front-end, Delphi 2010 Datasnap REST back-end
Newbie question - Datatables front-end, Delphi 2010 Datasnap REST back-end
Hi,
I have an existing application which requires a web front-end and Datatables looks like just the thing to get the bulk of the job done. I have a Delphi REST back end which if I call http://localhost/ISAPI/isapitest.dll/datasnap/REST/TServerMethods1/Contacts emits the following JSON :-
[code]
{
"result": [
[
{
"OID": 505,
"Number": "07863281972",
"FirstName": "Joe",
"LastName": "Smith"
},
{
"OID": 506,
"Number": "07868802482",
"FirstName": "Fred",
"LastName": "McCabe"
},
{
"OID": 508,
"Number": "07857665520",
"FirstName": "Andy",
"LastName": "Denton"
}
]
]
}
[/code]
I'm using the following code to instantiate my DataTables instance :-
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "/ISAPI/ISAPITest.dll/datasnap/rest/TServerMethods1/Contacts",
"sAjaxDataProp": "result[0][0]",
"aoColumns": [
{ "mDataProp": "OID" },
{ "mDataProp": "Number" },
{ "mDataProp": "FirstName" },
{ "mDataProp": "LastName" }
]
} );
} );
[/code]
All that happens is an empty table is displayed with the "Processing.." box for a while, then it just gives up. I'm not that familiar with the whole JS/JQuery stuff but I can't see anything obvious I've done wrong. I've tried setting bServerSide to true, but that doesn't make any difference. Does anyone have any ideas?
Thanks in advance,
Andy
I have an existing application which requires a web front-end and Datatables looks like just the thing to get the bulk of the job done. I have a Delphi REST back end which if I call http://localhost/ISAPI/isapitest.dll/datasnap/REST/TServerMethods1/Contacts emits the following JSON :-
[code]
{
"result": [
[
{
"OID": 505,
"Number": "07863281972",
"FirstName": "Joe",
"LastName": "Smith"
},
{
"OID": 506,
"Number": "07868802482",
"FirstName": "Fred",
"LastName": "McCabe"
},
{
"OID": 508,
"Number": "07857665520",
"FirstName": "Andy",
"LastName": "Denton"
}
]
]
}
[/code]
I'm using the following code to instantiate my DataTables instance :-
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "/ISAPI/ISAPITest.dll/datasnap/rest/TServerMethods1/Contacts",
"sAjaxDataProp": "result[0][0]",
"aoColumns": [
{ "mDataProp": "OID" },
{ "mDataProp": "Number" },
{ "mDataProp": "FirstName" },
{ "mDataProp": "LastName" }
]
} );
} );
[/code]
All that happens is an empty table is displayed with the "Processing.." box for a while, then it just gives up. I'm not that familiar with the whole JS/JQuery stuff but I can't see anything obvious I've done wrong. I've tried setting bServerSide to true, but that doesn't make any difference. Does anyone have any ideas?
Thanks in advance,
Andy
This discussion has been closed.
Replies
> "sAjaxDataProp": "result[0][0]"
to:
> "sAjaxDataProp": "result.0"
If that doesn't work, could you run your table through the DataTables debugger and let us know the debug code please.
Allan
That did it! I knew it would be something stupid.
Thanks very much for your prompt help. It's greatly appreciated. :)
Andy
Good to hear that did the business for you.
Regards,
Allan