Flask-AppBuilder icon indicating copy to clipboard operation
Flask-AppBuilder copied to clipboard

select record to filter another view

Open piccio123 opened this issue 2 years ago • 1 comments

Environment

Flask-Appbuilder version: 4.1.1

Expected results

I'd like to define an action in MyViewA (I followed this doc ) to filter another view MyViewB. To create the filter i used this doc.

models.py example

class TableA(Model):
   id = db.Column(db.Integer, primary_key=True)
   name = db.Column(db.String(100))


class TableB(Model):
  id = db.Column(db.Integer, primary_key=True)
  name = db.Column(db.String(100))
  id_a = db.Column(db.ForeignKey('tablea.id'), index=True)

  tablea = relationship('TableA', primaryjoin='TableB.id_a == TableA.id')

I need to create a view of TableA with an action on record selection that redirect on the view of TableB with a filter like

base_filters = [['id_a',FilterEqual, THE_ID_OF_THE_RECORD_SELECTED],]

Thanks in advance

piccio123 avatar Jun 07 '22 14:06 piccio123

Have a look at "related_views". I think that's it what are you looking for. https://flask-appbuilder.readthedocs.io/en/latest/quickhowto.html

ThomasP0815 avatar Jul 26 '22 11:07 ThomasP0815