display icon in cell
display icon in cell
Litash
Posts: 4Questions: 0Answers: 0
Hi Allan,
I am newbie in DataTables, and I like this plugin very much. I was wondering how to replace the data with an icon in a table cell. I am using Ajax data source and using mData to assign a function to the cell. My code is:
[code]
$('#CaseTable').dataTable({
"bProcessing": true,
"sAjaxSource": 'api/Case',
"sAjaxDataProp": "",
"bPaginate": true,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"aaSorting": [[7, 'asc']],
"bInfo": false,
"bAutoWidth": false,
"aoColumnDefs": [
{
"bSortable": false,
"aTargets": [0],
"mData":null
},
{
"bSortable": false,
"aTargets": [1],
"mData": null
},
{
"bSortable": false,
"aTargets": [2],
"mData": function (source, type) {
if (type === 'display') {
if (source.jointID != null) {
return '';
}
else if (source.jointID == null) {
return "";
}
}
}
},
{
"aTargets": [3],
"mData": "caseID"
},
{
"aTargets": [4],
"mData": "subject"
},
{
"aTargets": [5],
"mData": "category"
},
{
"aTargets": [6],
"mData": "caseStatus"
},
{
"aTargets": [7],
"mData": "feedbackDate"
},
{
"aTargets": [8],
"mData": "dueDate"
},
{
"aTargets": [9],
"mData": "caseOwner"
}
]
});
[/code]
The goal is to display an icon () in the cell with index [2] if the source.jointID is not a null value. Now the value is displayed successfully. But every time I reload the page, there is an pop up window says :
[quote] DataTables waring (table id = 'CaseTable'): Requested unknown parameter {mData function} from the data source for row 0 [/quote]
the data type of the jointID is a GUID in my database.
How to solve this problem? Can help me? Thanks in advance!!!
debug code: agicef
I am newbie in DataTables, and I like this plugin very much. I was wondering how to replace the data with an icon in a table cell. I am using Ajax data source and using mData to assign a function to the cell. My code is:
[code]
$('#CaseTable').dataTable({
"bProcessing": true,
"sAjaxSource": 'api/Case',
"sAjaxDataProp": "",
"bPaginate": true,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"aaSorting": [[7, 'asc']],
"bInfo": false,
"bAutoWidth": false,
"aoColumnDefs": [
{
"bSortable": false,
"aTargets": [0],
"mData":null
},
{
"bSortable": false,
"aTargets": [1],
"mData": null
},
{
"bSortable": false,
"aTargets": [2],
"mData": function (source, type) {
if (type === 'display') {
if (source.jointID != null) {
return '';
}
else if (source.jointID == null) {
return "";
}
}
}
},
{
"aTargets": [3],
"mData": "caseID"
},
{
"aTargets": [4],
"mData": "subject"
},
{
"aTargets": [5],
"mData": "category"
},
{
"aTargets": [6],
"mData": "caseStatus"
},
{
"aTargets": [7],
"mData": "feedbackDate"
},
{
"aTargets": [8],
"mData": "dueDate"
},
{
"aTargets": [9],
"mData": "caseOwner"
}
]
});
[/code]
The goal is to display an icon () in the cell with index [2] if the source.jointID is not a null value. Now the value is displayed successfully. But every time I reload the page, there is an pop up window says :
[quote] DataTables waring (table id = 'CaseTable'): Requested unknown parameter {mData function} from the data source for row 0 [/quote]
the data type of the jointID is a GUID in my database.
How to solve this problem? Can help me? Thanks in advance!!!
debug code: agicef
This discussion has been closed.
Replies
Allan
[code]
"aoColumnDefs": [
{
"bSortable": false,
"aTargets": [0],
"mData": "jointID ",
"mRender":
function (data, type, full) {
if (type === 'set') {
return;
}
else if (type === 'display') {
if (data !== "") {
return '';
}
}
else if (type === 'filter') {
if (data !== "") {
return '';
}
}
return '';
}
}
[/code]