CriteriaOptions: TextCriteriaOptions;
CriteriaOptions: Prognoz.Platform.Interop.Dimensions.TextCriteriaOptions;
The CriteriaOptions property sets search options.
To execute the example, place on the form the following components: Label named LABEL1, EditBox/TextBox named EDITBOX1/TEXTBOX1, two Button components named BUTTON1/BUTTON2, DimensionTree/DimensionTreeNet named DEMENTIONTREE1/DEMENTIONTREENET1, UiDimension/UiDimensionNet named UIDEMENTION1/UIDEMENTIONNET1 and MetabaseOpenDialog/MetabaseOpenDialogNet named METABASEOPENDIALOG1/METABASEOPENDIALOGNET1.
Change value of the Text property for the components: Label - the Search Text value, set the EditBox/TextBox component to empty value, the Button component named BUTTON1 set to Search, set the BUTTON1 component to Open. For the DimensionTree/DimensionTreeNet component, set the Dimension property to UiDimension1/UiDimensionNet1.
Add links to the Dimensions and Metabase system assemblies.
Class UserProc: Form
EditBox1: EditBox;
Button1: Button;
Button2: Button;
Label1: Label;
UiDimension1: UiDimension;
MetabaseOpenDialog1: MetabaseOpenDialog;
DimensionTree1: DimensionTree;
Function Search(DimInst: IDimInstance; SearchStr: String): IDimSelection;
Var
Result: IDimSelection;
TextCriteria: IDimTextCriteria;
OrmManager: IDimOrmManager;
Begin
If IsNull(dimInst) Or searchStr.IsEmpty Then
Return Result;
End If;
TextCriteria := New DimTextCriteria.Create;
TextCriteria.CriteriaOptions := TextCriteriaOptions.LikeText Or TextCriteriaOptions.SearchStringAttributes;
TextCriteria.Text := SearchStr;
Result := DimInst.CreateSelection;
OrmManager := New DimOrmManager.Create;
OrmManager.CreateCondition(DimInst.Dimension, TextCriteria).SelectElements(Result);
Return Result;
End Function search;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
UiDimension1.Selection := Search(UiDimension1.DimInstance, EditBox1.Text);
End Sub Button1OnClick;
Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
If MetabaseOpenDialog1.Execute(Self) Then
UiDimension1.Active := False;
UiDimension1.Dimension := MetabaseOpenDialog1.Object.Bind As IDimensionModel;
UiDimension1.Active := True;
End If;
End Sub Button2OnClick;
End Class UserProc;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Metabase;
…
Function Search(dimInst: IDimInstance; SearchStr: String): IDimSelection;
Var
Result: IDimSelection;
TextCriteria: DimTextCriteria;
OrmManager: IDimOrmManager;
Begin
If DimInst = Null Or String.IsNullOrEmpty(SearchStr) Then
Return Result;
End If;
TextCriteria := New DimTextCriteria.Create();
TextCriteria.CriteriaOptions := TextCriteriaOptions.tecropLikeText Or TextCriteriaOptions.tecropSearchStringAttributes;
TextCriteria.Text := SearchStr;
Result := DimInst.CreateSelection();
OrmManager := New DimOrmManager.Create();
OrmManager.CreateCondition(DimInst.Dimension, TextCriteria).SelectElements(Result, Null);
Return Result;
End Function Search;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Begin
UiDimensionNet1.Selection := search(UiDimensionNet1.DimInstance, TextBox1.Text);
End Sub;
Private Sub button2_Click(sender: System.Object; e: System.EventArgs);
Begin
If MetabaseOpenDialogNet1.Execute(Self) Then
UiDimensionNet1.Active := False;
UiDimensionNet1.Dimension := MetabaseOpenDialogNet1.Object.Bind() As IDimensionModel;
UiDimensionNet1.Active := True;
End If;
End Sub;
End Class;
After the form is started, click the Open button and select the dictionary. As a result, the form displays hierarchical list of dictionary elements. Enter text to search and click the Search button. As a result, the selection in the lists is changed: only the elements corresponding to search criteria are selected.
See also: