我想知道是否有人能帮我。在
我想能够点击客户和地点的基础上的某些客户,作为一个依赖下拉列表。此信息来自数据库,因此下面的代码中有查询。在
这是我对客户和位置的表单功能
class CustomerPick(SubForm):
customer = QuerySelectField(u'Customer',
get_label=u'sCustomer',
query_factory=lambda :
(TCustomer.query.order_by(TCustomer.sCustomer)),
validators=[DataRequired(),])
location = QuerySelectField(u'Location',
get_label=u'sLocation',
query_factory=lambda :
(TLocation.query.order_by(TLocation.sLocation)),
validators=[DataRequired(),])
这是视图部分
^{pr2}$这是一个下拉列表的图片也供参考,如果有任何其他需要让你们尝试一下,请让我知道。提前谢谢! Photo
我不太明白你的问题,但你希望能够点击一个用户,并根据位置填充下拉列表?在
这涉及到一些Ajax来回发送数据。 我将给你一个代码片段的最小化版本(未测试)。在
总之,这里的想法是使用
.change
捕捉用户行为,然后根据更改,将带有用户标识符的请求发送到服务器端。一旦它到达服务器端,您将在数据库中进行查询,并使用不同的处理表单再次呈现相同的模板。在最好的方法是,一旦将user_标识符放入视图中,进行查询并返回jsonified location对象,然后在成功块中更改下拉输入元素的。在
如果你有更多问题请告诉我。在
相关问题 更多 >
编程相关推荐