【发布时间】:2016-10-14 11:33:26
【问题描述】:
有没有办法将行作为 html 添加到数据表中?我知道建议的做法是这样的:
$('#addRow').on( 'click', function () {
t.row.add( [
counter +'.1',
counter +'.2',
counter +'.3',
counter +'.4',
counter +'.5'
] ).draw( false );
counter++;
} );
但是我有一个复杂的 JSON 输入,我想在 PHP 中对其进行预处理。是否可行甚至可能?
编辑:
所以不要做上面的代码:
t.row.add(resultfromphpserverwithalltherows);
更新:
JSON 输出
{"student":[{"id":"2008-161","name":"Joseph Taylor","age":"20","status":"married","address":"USA","subjects":[{"math":"90","science":96,"history":99,"literature":93,"pe":"96"}],"remarks":"passed"}
有时:
{"student":[{"id":"2008-161","name":"Joseph Taylor","age":"20","status":"married","address":"USA","subjects":[{"math":"90","science":96,"history":99,"literature":93,"pe":"96"}],"remarks":"passed","othersubjects":[{"applied math":"90","general science":96,"world history":99,"literature":93,"pe":"96"}],"remarks":"passed"}
所以我无法真正定义列,因为 JSON 输出是动态的,这就是为什么我想先在 PHP 中对其进行预处理。
【问题讨论】:
标签: php jquery ajax twitter-bootstrap datatable