【发布时间】:2012-01-31 20:32:36
【问题描述】:
我正在使用数据表显示数据库表值。我正在使用 ajax 方法执行此操作。这是代码
$('#example1').dataTable( {
"bProcessing": true,
"sAjaxSource": "filename.php",
"bJQueryUI": true,
"sPaginationType": "full_numbers"
} );
filename.php 的输出是
{ "aaData": [["1","<input type='checkbox' name='user'> Test Name","Leader","35"]] }
html代码是
<table cellpadding="0" cellspacing="0" border="0" class="display tablehead" id="example1">
<thead>
<tr class="colhead newbg">
<th width="17" align="center">No</th>
<th width="194" align="left">User</th>
<th width="56" align="left">Role</th>
<th width="31" align="right">AGE</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
在上面的 html 中,您可以看到第一列居中对齐,接下来的两列左对齐,最后一列右对齐。但是在输出的数据中,所有的都是中心对齐的。我尝试使用以下
{ "aaData": [["<div align='center'>1</div>","<div align='left'><input type='checkbox' name='user'> Test Name</div>","<div align='center'>Leader</div>","<div align='right'>35</div>"]] }
现在我得到了正确的显示,但是按年龄排序时它不正确。请帮忙。谢谢
【问题讨论】:
标签: php jquery css ajax datatables