Jump to content

How to Build A Reset Button For Resetting All Filter of an Active Page with Multiple Data Table Columns


Sharan Venkata

Recommended Posts

Hi,

 

I've a scenario where in the reset button should reset all the filters of a page which has multiple data table filter columns in a filter panel. Can you please provide a solution for this For now, I've the script to reset the filters of columns which belong to only one data table.

Iron Python Script:

#It resets the filters and markings in Orion_data table to default.

from Spotfire.Dxp.Application import Filters as filters

from Spotfire.Dxp.Data import DataManager

from Spotfire.Dxp.Data import IndexSet

from Spotfire.Dxp.Data import RowSelection

#It clears marking in DataTable1.

marking=Application.GetService[DataManager]().Markings["Marking1"]

dataTable=Document.Data.Tables["DataTable1"]

selectRows = IndexSet(dataTable.RowCount, False)

marking.SetSelection(RowSelection(selectRows),dataTable)

#It resets all filters in DataTable1.

dataTable=Document.Data.Tables["DataTable1"]

for filteringScheme in Document.FilteringSchemes:

filteringScheme[dataTable].ResetAllFilters()

 

 

Any help is highly appreciated.

 

Best Regards

Sharan

Link to comment
Share on other sites

Hi Gaia Paolini,

 

 

 

No, the preset functions would not do the job as they reset all filters and markings in the entire dashboard.

 

However, my requirement is to reset the filters and markings of pages that use the same data table to build the charts and filters. In addition to this, the reset button I'm looking for is when the button is clicked, the filters selected from column1 from datatable1, and column2 from datatable2 should be reset. Currently I only have the script that resets only the column1 from datatable1 but not column2 from datatable2.

 

Hope this explanation gives better understanding

 

Regards

 

Sharan 

Link to comment
Share on other sites

I am not 100% sure I got the spec right, but you should have all the pointers for modifying this the way you need: check the indentation as it was somewhat lost in the copy and paste

 

from Spotfire.Dxp.Application import *

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Framework.DocumentModel import *

from Spotfire.Dxp.Application.Filters import *

 

#find all visuals on the current page

thisPageVisuals=Application.Document.ActivePageReference.Visuals

 

#find all data tables on the current page - these are our focus data tables

thisPageData=[]

for vv in thisPageVisuals:

if (vv.TypeId != VisualTypeIdentifiers.HtmlTextArea): #a text area has no data tables

vvd=vv.As[VisualContent]().Data.DataTableReference

thisPageData.append(vvd)

 

#################

#reset all filtering schemes for these data tables

for fs in Application.Document.FilteringSchemes:

for dt in thisPageData:

try:

fs[dt].ResetAllFilters()

except:

pass

 

#################

#from all pages check all visuals

#and reset the markings in the visuals that contain our focus data tables

for pp in Application.Document.Pages:

for vv in pp.Visuals:

if (vv.TypeId != VisualTypeIdentifiers.HtmlTextArea): #a text area has no data tables

vvd=vv.As[VisualContent]().Data.DataTableReference

if (vvd in thisPageData):

marking=vv.As[VisualContent]().Data.MarkingReference

rows = RowSelection(IndexSet(vvd.RowCount, False))

marking.SetSelection(rows, vvd)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...