Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81669

Consume legacy REST API (map TotalRows to iTotalRecords)

$
0
0
I wish to use datatables with an existing REST service that supports paging but has it's own parameters/return values (e.g. iTotalRecords is TotalRows). I can't change the server code as it'll break existing apps.

sAjaxDataProp let's you select the "aaData" field but there doesn't seem to be any equivalent for iTotalRecords etc. Also, the server is expecting the fields pageSize and page for pagination handling.

How do I go about mapping these fields?

"fnServerData": function (sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function (json) {
alert(json.TotalRows); <----------- would be a good spot to set the values
fnCallback(json)
})

Viewing all articles
Browse latest Browse all 81669

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>