Jump to content

Filter rows in datatable based on marked selection from another datatable


Spencer Trinh

Recommended Posts

I have a column from a datatable_1 titled, "QuinnMatches" that will either be a single string or a list of strings. I want the user to be able to select a row in datatable_1 and it automatically filter datatable_2 which is all the possible samples from QuinnMatches. This is what I tried but it doesn't work, I am complete newbie, hope to find some help here. Took snippets of code from :https://community.spotfire.com/wiki/how-create-data-table-based-filtered-rows-another-data-table-tibco-spotfirer-using-ironpython

My version of Spotfire Analyst is 10.3.1.9

 

Appreciate your help!

 

from Spotfire.Dxp.Data import DataValueCursor,DataManager, DataSelectionCombinationMethod

from Spotfire.Dxp.Application.Visuals import VisualContent

from Spotfire.Dxp.Application.Filters import *

import Spotfire.Dxp.Application.Filters.ListBoxFilter

from Spotfire.Dxp.Application.Visuals import VisualContent

 

def output_quinn_cmpds(quinn_cmpds):

lst_quinn_cmpds = []

if len(quinn_cmpds) > 8:

lst_quinn_cmpds = quinn_cmpds.split()

else:

lst_quinn_cmpds.append(quinn_cmpds)

return lst_quinn_cmpds

 

 

qviz_var = quinn_viz.As[VisualContent]()

dt_quinn = Document.Data.Tables["Quinn Compounds"]

dt_mark = Document.ActiveMarkingSelectionReference

marked_rows = dt_mark.GetSelection(dt_nsc)

index = -1

 

 

for row in marked_rows.AsIndexSet():

index = index + 1

if row[index] == True:

print('highlighted')

column_qm = dt_nsc.Columns["QuinnMatches"]

cursor_qm = DataValueCursor.Create[str](column_qm)

for r in dt_nsc.GetRows(index, cursor_qm):

#print cursor_qm.CurrentValue

output_quinn_cmpds(cursor_qm.CurrentValue)

else:

print('not highlighted')

#

for qcmpds in output_quinn_cmpds:

#selectCol = dt_nsc.Select("QuinnMatches = '{0}'".format(qcmpds))

#cursor = DataValueCursor.CreateFormatted(dt_nsc.Columns["NSC"]

#display only those elemnts in output_quinn_cmpds on the second (other) datatable

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...