jquery - 使用 django 排序呈现的 jQuery 数据表不起作用
问题描述
我似乎无法在点击时订购此表。该应用程序正在从 Django 检索表并成功呈现它。但是,当我继续单击表格列顶部的箭头时,会出现一个框显示“正在处理”,但不会发生重新排序。当我以编程方式禁用serverSide
它以使其仅在第一次发生时,ajax 调用无论如何都会发生。
$(document).ready( function () {
$.fn.dataTable.ext.errMode = 'throw';
var table = $('#{{ grid_id }}').DataTable({
"paging": {{paging}}
,"searching": false
,"info": true
,"stateSave": false
,"orderable": true
,"ordering": true
,"processing": true
,"serverSide": true
{% if ajax_url is not None %}
,"ajax": {
/* "type": "POST", */
"url": "{{ ajax_url }}",
"dataSrc": "results",
"data": function (d) {
d.customParam = "custom";
}
}{% endif %}{% if column_list is not None %}
,"columns": [
{% for col in column_list %} { "title":"{{ col.title }}", "data": "{{ col.data }}"
{% if col.href is not None %}, fnCreatedCell: function (nTd, sData, oData, iRow, iCol) { $(nTd).html("<a href='{{col.href}}"+oData.{{ col.href_data_attr }}+"'>"+oData.{{ col.data }}+"</a>");}{% endif %}
},{% endfor %}
]
{% endif %}
});
});
解决方案
推荐阅读
- docker - nodeRegistration.criSocket:无效值:“/var/run/dockershim.sock”:路径不是绝对的
- c++ - 如何从 boost log sink 组织线程安全读取?
- javascript - 使用 Vue JS 显示分组的嵌套数组
- android - 从元素的特定子元素中获取元素的属性值
- docker - 将作曲家连接到个性化织物的过程
- corda - Corda 状态持续存在于 DB 中的确切位置(IOU 示例)
- javascript - 在 iFrame 中定位元素时遇到问题
- mongodb - Mongodb中非常慢的日期范围查询
- vba - 告诉 VBA 查看 64 位注册表视图
- reactjs - 如何在 ReactJS 中的按钮上添加多个 onClick 函数