In the fnRender I return a div to which I can then set the title - I can then use (for my title value) any field from my passed-in oObj.
Ex: In the code below, I display in the table cell a short string repesenting a date (actually, only day and month) while in the title (aka tooltip for that cell), I display the full date and time including timezone, converted from the json as serialized by mvc (thus the extra code to read that date):
[code]
var otbl = $('#someTable').dataTable({
"sAjaxSource": someUrl,
"fnServerData": function (url, data, callback) {
$.ajax({
"url": url,
"data": data,
"success": callback,
"contentType": "application/x-www-form-urlencoded; charset=utf-8",
"dataType": "json",
"type": "POST",
"cache": false,
"timeout": 60000,
"error": function (jqXHR, textStatus, errorThrown) {
if (otbl != undefined)
otbl.fnProcessingIndicator(false);
if (textStatus === "timeout") {
alert("Downloading data has timeout. ");
} else {
alert("Downloading data has failed. Error: " + textStatus);
}
}
});
},
"sDom": 'ritS',
"aoColumns": [{ "mDataProp": "LogDateDisplay", "fnRender": function (oObj) {
return '' +
oObj.aData.LogDateDisplay + ''; } }
],
"bServerSide": true
});
[/code]
where the code to parse the mvc json date is (and you can ignore it as not part of your question though):
[code] new Date(parseInt(oObj.aData.LogDate.replace("/Date(", "").replace(")/", ""), 10))[/code]
Looks good - thanks for sharing your solution with us. fnRender is certainly a good option if you want to build the whole HTML string dynamically - if you want to add the attribute to a node, then fnCreatedCell or fnCreatedRow are there to provide that option.
Replies
Allan
Ex: In the code below, I display in the table cell a short string repesenting a date (actually, only day and month) while in the title (aka tooltip for that cell), I display the full date and time including timezone, converted from the json as serialized by mvc (thus the extra code to read that date):
[code]
var otbl = $('#someTable').dataTable({
"sAjaxSource": someUrl,
"fnServerData": function (url, data, callback) {
$.ajax({
"url": url,
"data": data,
"success": callback,
"contentType": "application/x-www-form-urlencoded; charset=utf-8",
"dataType": "json",
"type": "POST",
"cache": false,
"timeout": 60000,
"error": function (jqXHR, textStatus, errorThrown) {
if (otbl != undefined)
otbl.fnProcessingIndicator(false);
if (textStatus === "timeout") {
alert("Downloading data has timeout. ");
} else {
alert("Downloading data has failed. Error: " + textStatus);
}
}
});
},
"sDom": 'ritS',
"aoColumns": [{ "mDataProp": "LogDateDisplay", "fnRender": function (oObj) {
return '' +
oObj.aData.LogDateDisplay + ''; } }
],
"bServerSide": true
});
[/code]
where the code to parse the mvc json date is (and you can ignore it as not part of your question though):
[code] new Date(parseInt(oObj.aData.LogDate.replace("/Date(", "").replace(")/", ""), 10))[/code]
hth
Allan