根据documentation,使用order_columns
可以指定哪些列允许排序,这会在标题中添加蓝色箭头以选择升序或降序排序
然而,我也希望通过一个名为“softwareproduct”的关系对另一个表进行排序,但当我将其添加到order_列时,它崩溃了(因为它不是一个真正的列,而是一个关系)。该文档还列出了order_rel_字段,我也尝试过了,但没有为“softwareproduct”列/关系添加排序功能:
添加列、编辑列、显示列和列表列都能很好地工作,只有顺序不能,即使“softwareproduct”从技术上讲不是一个真正的列,而是一种关系
我如何让用户根据这些关系进行排序
[...]
class Softwareproduct(Model):
suffix = Column(String(200), primary_key=True)
label = Column(String(200), nullable=False)
[...]
def __repr__(self):
return self.label
class Citation(Model):
suffix = Column(String(200), primary_key=True)
swp_suffix = Column(String(200), ForeignKey("softwareproduct.suffix"),nullable=False)
softwareproduct = relationship("Softwareproduct")
label = Column(String(200), nullable=False)
def __repr__(self):
return self.label
class CitationView(ModelView):
datamodel = SQLAInterface(Citation)
label_columns = {'label':'Citation', 'suffix': 'ID'}
add_columns = ['softwareproduct', "label", "suffix", "classified"]
edit_columns = ['softwareproduct', "label", "suffix","classified"]
show_columns = ['softwareproduct', "label", "suffix","classified"]
list_columns = ['softwareproduct', "label", "suffix","classified"]
order_columns= ["label","suffix"]
order_rel_fields = {'softwareproduct': ('label', 'asc')}
related_views = [ClassifiedView]
改变
到
相关问题 更多 >
编程相关推荐