1
我曾經使用PHP打印我的數據表。當我到了一個字符串大於17個字符的特定列,我會用下面的17字符後打印橢圓:如果數據長度大於特定長度,jquery datatable
if(strlen($row[tli]) > 17){echo "<td><a href='#'>".substr(row['number'],0,17)."..."</a></td>";}
我需要做什麼用ajax不是一回事。
$('#example1').DataTable({
"ajax": {
"url": "api/displayQnams.php",
"type": "POST",
"dataSrc": ''
},
"columns": [
{
"data": "number",
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol)
{
if(oData.number.length > 17) // here is where the initial check starts
{$(nTd).html("<a href='#'>'"+oData.number+"...'</a>")} // here is where it should print the ellipses after the 17th character
else
{$(nTd).html("<a href='#'>'"+oData.number+"'</a>"}
}
}
]
});
oData.number.length讓我在控制檯以下錯誤:
Cannot read property 'length' of undefined
我缺少什麼,使這項工作?
預先感謝您。