Andrew Hue Posted December 12, 2017 Share Posted December 12, 2017 Hello there, I've been trying to find a way to delete a marked row(s) where one of the columns matches a specific value. In this case, I want to allow deleting rows only when a "username" attribute matches the current username.Here's what I have so far: from Spotfire.Dxp.Data import * from System.Threading import Thread #assign marked rows into variable selectedRows = Document.Data.Markings["Marking"].GetSelection(Document.Data.Tables["MyTable"]) #create data cursor on a the "Username" column cursor = DataValueCursor.CreateFormatted(Document.Data.Tables["MyTable"].Columns["Username"]) #loop through the column rows, then retrieve the values and then check against current username. for row in table.GetRows(cursor): value = cursor.CurrentValue if value == Thread.CurrentPrincipal.Identity.Name: Document.Data.Tables["MyTable"].RemoveRows(selectedRows)Anyone know the right way to do this Would appreciate any help! Thanks. Link to comment Share on other sites More sharing options...
Nawaz Ali Mohammad Posted December 13, 2017 Share Posted December 13, 2017 My best would be is to use the conditions you want under "Hide/Show items" option or using "Limit data using expression". Link to comment Share on other sites More sharing options...
Andrew Hue Posted January 2, 2018 Author Share Posted January 2, 2018 Hi Nawaz, Thanks for the reply. But I really need some type of interactive way for users to select and delete a marked row from a table visualization. Hopefully, someone reading this post would be able to share some way to do this... Link to comment Share on other sites More sharing options...
Matthew Stahl Posted April 11, 2019 Share Posted April 11, 2019 Hi Anthony, Give this script a shot: from Spotfire.Dxp.Data import * from System.Threading import Thread #assign marked rows into variable table = Document.Data.Tables["MyTable"] markedRows = Document.Data.Markings["Marking"].GetSelection(table) userRows = table.Select("[username] = '%s'" % Thread.CurrentPrincipal.Identity.Name) set1 = IndexSet(markedRows.AsIndexSet()) set2 = IndexSet(userRows.AsIndexSet()) rowSelection = RowSelection(set1.And(set2)) table.RemoveRows(rowSelection) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now