1
PHPを使用してデータテーブルを印刷したことがあります。私はより大きい17文字の文字列を持っていた特定の列に着いたとき、私は17文字の後に楕円を印刷するには、次の使用します。データ長が特定の長さより大きい場合、jqueryのデータ変換可能
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
私はこの仕事をするために何をしないのですか?
ありがとうございます。