【发布时间】:2016-12-02 04:19:01
【问题描述】:
刚从 php、datatables 和 jeditable 开始,我可以让我的表加载并且看起来不错,当我单击表中的记录时,它可以让我编辑记录,当我查看 dataOut 时我正在获取数据。 chrome开发者工具中的php文件,但它没有传递记录标识符。
<script type="text/javascript">
$(document).ready(function() {
$('#users').dataTable( {
} );
/* Init DataTables */
var oTable = $('#users').dataTable();
/* Apply the jEditable handlers to the table */
oTable.$('td').editable( 'dataOut.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
window.location.reload();
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id_user'),
"column": oTable.fnGetPosition( this )[2]
}
},
"height": "14px",
"width": "100%"
} );
} );
</script>
<table id="users" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>id</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
<th>Name</th>
<th>Role Code</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM `users`";
foreach ($conn->query($sql)as $row){
echo '<tr>';
echo '<td>' . $row['id_user'] . '</td>';
echo '<td>' . $row['firstname'] . '</td>';
echo '<td>' . $row['lastname'] . '</td>';
echo '<td>' . $row['username'] . '</td>';
echo '<td>' . $row['realname'] . '</td>';
echo '<td>' . $row['role'] . '</td>';
echo '</tr>';
}
?>
</tbody>
<tfoot>
<tr>
<td>id</td>
<td>iFirstname</td>
<td>Lastname</td>
<td>Username</td>
<td>Name</td>
<td>Role Code</td>
</tr>
</tfoot>
</table>
当我将姓氏从 Lewis 更改为 Lane 时,这是 chrome developer 中的结果
array(4) { ["value"]=> string(4) "Lane" ["id"]=> string(0) "" ["row_id"]=> string(0) "" ["列"]=> 字符串(1) "2" }
【问题讨论】:
标签: php jquery datatables jeditable