在django-tables2中,默认情况下所有表列都支持排序。这意味着所有列标题都被呈现为允许用户调整表数据顺序的链接。但我不希望列标题呈现为链接,如何做到这一点?在
这是文件!在
默认情况下,所有表列都支持排序。这意味着所有列标题都被呈现为允许用户调整表数据顺序的链接。在
可以基于表或列禁用排序。在
Table.Meta.orderable = False – default to disable ordering on columns
Column(orderable=False) – disable ordering for specific column
例如,禁用除一个以外的所有列:
^{pr2}$我做过,但没有工作。这个是我的吗塔贝斯.py文件:
class MusicBaseTable(tables.Table):
songs = tables.CheckBoxColumn()
title = tables.Column()
artist = tables.Column()
album = tables.Column()
genre = tables.Column()
date = tables.Column()
class Meta:
orderable = False
attrs = {"class": "list"}
在the documentation:
请看the template如何决定列是否应该具有order链接:
{% if column.orderable %}
相关问题 更多 >
编程相关推荐