我正在通过以下脚本按需创建转换(覆盖特定值):
from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Data.Transformations import *
from System.Collections.Generic import List, Dictionary
from Spotfire.Dxp.Data import DataTable
from System.Collections import ArrayList
#Get values to establish the key of the table
overrideMonth = str(Document.Properties['OverrideMonth'])
overrideItem = str(Document.Properties['OverrideItem'])
overrideCustomer = str(Document.Properties['OverrideCustomer'])
overrideKey = overrideMonth[:-11].strip() + '~' + overrideItem + '~' + overrideCustomer
#Get existing value based on this key
table=Document.Data.Tables['MasterOverride']
rowSelection = table.Select('KeyColumn = ' + '"' + overrideKey + '"')
cursor = DataValueCursor.CreateFormatted(table.Columns["Override Value"])
for row in table.GetRows(rowSelection.AsIndexSet(),cursor):
rowIndex = row.Index
currentOverrideValue = cursor.CurrentValue
break
#Get values to actually write out
overrideValue = Document.Properties['OverrideValue']
#Replace specific value Transformation for the Value
dataOperation = table.GenerateSourceView().OperationsSupportingTransformations[0];
transformations = dataOperation.GetTransformations();
column = DataColumnSignature("Override Value",DataType.Real);
row_id_cols=[DataColumnSignature("KeyColumn",DataType.String)]
row_id_col_values = [overrideKey]
transformations.Add(ReplaceSpecificValueTransformation(column, float(currentOverrideValue), overrideValue, row_id_cols, row_id_col_values, False))
dataOperation.ReplaceTransformations(transformations);
这对实现新的转换非常有用。但是现在,我想根据月,物料和客户的相同输入,使他们能够删除他们可能添加的转换。现在,我可以使用以下脚本删除所有转换:
from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Data.Transformations import *
table=Document.Data.Tables['MasterOverride']
#Replace specific value Transformation
dataOperation = table.GenerateSourceView().OperationsSupportingTransformations[0];
transformations = dataOperation.GetTransformations();
#clear all transformations on this dataTable if needed
dataOperation.ReplaceTransformations("")
但是我不确定如何删除特定的转换。注意,它们都是ReplaceSpecificValueTransformation
类型。