How to assign the data to mData from fnRender return value

How to assign the data to mData from fnRender return value

mohaideenmohaideen Posts: 10Questions: 3Answers: 0
edited April 2014 in DataTables 1.10
I am using DataTable with google map. I getting latitude and longitude from server side json. Here i have changing to address and that address is assigned to DataTable data(TD). BUt it gives error.

[code]
var geocoder;
geocoder = new google.maps.Geocoder();
var DataTable = $('#DataTable').dataTable({

"sAjaxSource": "php/totalDevices.php",
"aoColumns": [{
"mData": "name",
"sTitle": "User Name"
}, {
"mData": "managerName"
}, {
"mData": "imei"
}, {
"mData": "email"
}, {
"mDataProp": null,
"mData": null,
"fnRender":function ( obj ) {
var latlng = new google.maps.LatLng(obj.aData['latitude'], obj.aData['longitude']);
geocoder.geocode({
'latLng': latlng
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var address = results[0].formatted_address;
console.log(address);
return address;
//callback(address);
} else {
alert('No results found');
}
} else {
alert('Geocoder failed due to: ' + status);
}
});
//return getAddress(obj.aData['latitude'],obj.aData['longitude']);
},

}],

});
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Firstly I would very much suggest you don't use fnRender . It is deprecated in 1.9 and removed in 1.10.

    Secondly, can you please link to a test page showing the issue if you can't get it to work with mRender (the replacement for fnRender).

    Allan
  • mohaideenmohaideen Posts: 10Questions: 3Answers: 0
    How to get server side json value in mRender. I have like this: device={id:"", info:{},{},{}}
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Use the third parameter that is passed into mRender which gives you the full row. From the documentation:

    > {array|object} The full data source for the row (not based on mData)

    Allan
This discussion has been closed.