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
我缺少什么,使这项工作?
预先感谢您。