How to assign the data to mData from fnRender return value
How to assign the data to mData from fnRender return value
mohaideen
Posts: 10Questions: 3Answers: 0
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]
[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]
This discussion has been closed.
Replies
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
> {array|object} The full data source for the row (not based on mData)
Allan