Cha*_*had 6 javascript php ajax jquery datatables
我正在使用DataTables进行流水线操作.我工作得很好,除非我试图输入一个额外的列来保存"编辑"链接.见这个表.
这是一个显示列的server_processing.php片段:
/* Array of database columns which should be read and sent back to DataTables.
* Use a space where you want to insert a
* non-database field (for example a counter or static image)
*/
$aColumns = array( 'user','email', );
Run Code Online (Sandbox Code Playgroud)
这是客户端:
$(document).ready( function (){
$('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "scripts/server_processing.php",
"fnServerData": fnDataTablesPipeline,
aoColumns: [null, null, {"bSortable": false}]
}).makeEditable({
sUpdateURL: "UpdateData.php",
sAddURL: "AddData.php",
sAddHttpMethod: "POST",
sDeleteURL: "DeleteData.php",
sDeleteHttpMethod: "POST",
aoColumns: [ { } , { } , null ]
});
});
Run Code Online (Sandbox Code Playgroud)
那么,为什么这不起作用?
我自己也做了同样的事情。我喜欢使用 配置我的所有列aoColumnDefs,因为您可以一次性为列添加多个配置选项。
// Disable sorting on the 3rd column
'aoColumnDefs': [{'aTargets': [2], 'bSortable': false}]
Run Code Online (Sandbox Code Playgroud)
请注意,这aTargets是您想要应用这些设置的列索引数组。因此,如果您要添加更多链接列(例如删除链接),您可以关闭这些链接列的排序,而无需每次都重写列定义。
// Disable sorting on the 3rd and 4th column
'aoColumnDefs': [{'aTargets': [2,3], 'bSortable': false}]
Run Code Online (Sandbox Code Playgroud)
而且,正如我所说,您可以为同一数组中的列添加更多配置选项:
// Disable sorting on the 3rd and 4th column and sort 1st column by string
'aoColumnDefs': [
{'aTargets': [2,3], 'bSortable': false}
{'aTargets': [0], 'sType': 'string'}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1934 次 |
| 最近记录: |