Tom Tang 2 Posted August 23, 2019 Share Posted August 23, 2019 hi there I am using an ironpython script to sort the marked rows in a datatable, so when every time users mark rows in a table, these marked rows will appear in the font of the data table steps: 1, create a tag collection TAGcollection1 and tags MarkedRows and Untagged for data table DT1 2, attach marked rows to tag MarkedRows 3, add tag coloumnTAGcollection1 to the data table and set sort by ASC 4, create a button and a script script parameter: myTable1 and myTag1 (set to DT1 and TAGcollection1 ) script content: ================================================================= from System.Reflection import Assembly from Spotfire.Dxp.Data.Collections import * from System.Runtime.Serialization import ISerializable from System.Collections import IComparer from System.Collections.Generic import IComparer from Spotfire.Dxp.Data import DataColumn, TagsColumn from Spotfire.Dxp.Data import DataPropertyClass, DataType, DataValueCursor, IDataColumn, IndexSet from Spotfire.Dxp.Data import RowSelection ##tagging # Tag the marked rows markedRowSelection = Document.ActiveMarkingSelectionReference.GetSelection(Document.ActiveDataTableReference) table = Document.ActiveDataTableReference myTagColumn = table.Columns.Item[myTag1].As[TagsColumn]() selectRows = IndexSet(table.RowCount, True) #tags = myTagColumn.TagValues myTagColumn.Tag('Untagged', RowSelection(selectRows)) myTagColumn.Tag('MarkedRows', markedRowSelection) ##sorting values = Document.Data.Tables[myTable1].Columns[myTag1].RowValues.GetEnumerator() myValues = [] for val in values: myValues.Add(val.ValidValue) myValues.sort() print myValues Document.Data.Tables[myTable1].Columns[myTag1].Properties.SetCustomSortOrder(myValues) =================================================================================== issues; 1) when I do these for DT1, it works fine 2) but when I do the same for another DT2 with TAGcollection2, issues appear: a) when marking in DT2, the sorting works but there is error notification: column "TAGcollection1 "(not TAGcollection2) does not exist in collection b) then I create the same TAGcollection1 for DT2 also the error notification is gone, but I found that when I mark for DT2, DT1 will be UNMARKED there is no relation b/w two tables I am not sure why these two datatables are messing up each other thru tags 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