Express > Express Assembly Interfaces > IEaxDataAreaValidationChain > IEaxDataAreaValidationChain.Move
Move(FromIndex: Integer; ToIndex: Integer);
FromIndex. Index of validation rule position from which validation rule must be moved.
ToIndex. Index of the position, to which validation rule must be moved.
The Move method moves validation chain elements.
The method is executed only if the collection contains more than one validation rule.
Executing the example requires that the repository contains a regular report with the REG_REPORT_VALIDATIONS identifier, for which time series database is a data source. The report contains two validation rules.
Add links to the Drawing, Express, Laner, Metabase, Ms, Pivot, Report, Tab system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Validation: IValidationFilter;
Report: IPrxReport;
DataArea: IEaxDataArea;
AreaSlice: IEaxDataAreaSlice;
EaxValidations: IEaxDataAreaValidations;
EaxValidation, EaxValidation1: IEaxDataAreaValidation;
i, k, m, index: integer;
Grid: IEaxGrid;
DiagReport: IDiagnosticReport;
Chain: IEaxDataAreaValidationChain;
ValidationLink: IEaxDataAreaValidationLink;
Validations: IEaxDataAreaValidations;
ValidationsCount: Integer;
LinkSource: IEaxDataAreaValidation;
Id: String;
ValidFilterSetting: IValidationFilterSettings;
TabCellStyle: ITabCellStyle;
Color: IGxColor;
Brush: IGxSolidBrush;
DataAreaValidation: IEaxDataAreaValidation;
Level: IValidationLevel;
Begin
// Get repository
MB := MetabaseClass.Active;
// Get regular report
Report := MB.ItemById("REG_REPORT_VALIDATIONS").Edit As IPrxReport;
// Get analytical data area
DataArea := Report.DataArea;
// Get data slice
AreaSlice := DataArea.Slices.Item(0);
For i := 0 To AreaSlice.Views.Count - 1 Do
If Areaslice.Views.Item(i) Is IEaxGrid Then
// Get data table
Grid := AreaSlice.Views.Item(i) As IEaxGrid;
// Create a diagnostic report
DiagReport := New DiagnosticReport.Create;
{Bind validation chain of diagnostic report with the collection
regular report validation rules}
DiagReport.Grid := Grid;
Break;
End If;
End For;
// Get validation chain
Chain := DiagReport.Chain;
// Get collection of validations in chain
Validations := Chain.Validations;
// Get and display the number of validations in chain in the console window
ValidationsCount := Validations.Count;
Debug.WriteLine("Number of validations in chain = " + ValidationsCount.ToString);
// Display slice parent object identifier in the console window
For k := 0 To Chain.Count - 1 Do
ValidationLink := Chain.Item(k);
If ValidationLink.Enabled = False Then
ValidationLink.Enabled := True;
End If;
LinkSource := ValidationLink.Source;
Id := LinkSource.Id;
Debug.WriteLine("Slice parent object identifier - " + Id);
End For;
// Move validation chain elements
Chain.Move(1, 0);
// Get collection of validation rules
EaxValidations := AreaSlice.Validations;
// Clear collection of validation rules
EaxValidations.Clear;
// Create validation rules
EaxValidation := EaxValidations.Create;
// Add a new validation rule
EaxValidation1 := EaxValidations.Add(EaxValidation);
// Display validation rule index in the console window
For m := 0 To EaxValidations.Count - 1 Do
DataAreaValidation := EaxValidations.Item(m);
Index := EaxValidations.IndexOf(DataAreaValidation);
Debug.WriteLine("Validation rule index = " + Index.ToString);
End For;
// If a rule by the a key is found, it is deleted
If EaxValidations.FindByKey(1) <> Null Then
EaxValidations.RemoveByKey(1);
End If;
// Get filter
Validation := EaxValidation.Filter As IValidationFilter;
If Validation <> Null Then
// To calculate validation, use data start/end date
Validation.StartDateSettings.DateOptions := ValidationDateOptions.DependsFromData;
Validation.EndDateSettings.DateOptions := ValidationDateOptions.DependsFromData;
// Get filter settings
ValidFilterSetting := Validation.Settings;
// Validation type - compare with number
Validation.Kind := ValidationDetailsKind.Level;
// Get validation type settings
Level := Validation.Details As IValidationLevel;
// Comparison operator - greater than the specified number
Level.ComparisonValue.ComparisonOperator := ValidationComparisonOperator.More;
// Set number for comparison
Level.ComparisonValue.Value1 := 0;
// Get cell style
TabCellStyle := ValidFilterSetting.CellStyle.TabStyle;
// Change background color or the cells satisfying validation rule
Color := New GxColor.CreateRGB(120, 0, 120);
Brush := New GxSolidBrush.Create(Color);
TabCellStyle.BackgroundBrush := Brush;
// Change text of cells satisfying validation rule
TabCellStyle.Text := "Text";
End If;
// Refresh report and save changes
Report.Recalc;
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example:
The console window displays the number of validations in chain.
The console window displays identifier of slice data source parent object.
Validation chain element is moved.
The console window displays validation rule index.
If the rule with key 1 is found, it is removed.
A validation rule with parameters is created, by which table is formatted.
See also: