ItemById(Id: Integer): IPrxDocumentObject;
ItemById(Id: Integer): Prognoz.Platform.Interop.Report.PrxDocumentObject;
Id. Object identifier in the collection.
The ItemById method returns object parameters by its identifier.
The object identifier can be obtained in the IPrxDocumentObject.Id property. Object identifiers are generated automatically on inserting charts or chart legends on the table sheet. The ItemById method is relevant for use, if there is any identifier or it is not necessary to look over the entire collection by using the Item-Count properties.
Executing the example requires that the repository contains a regular report with the Report identifier. The report contains the text sheet that is named Document, charts and chart legends are added on the sheet.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
Doc: IPrxDocument;
DocObjects: IPrxDocumentObjects;
DocObject: IPrxDocumentObject;
i: Integer;
IdArray: IArrayList;
Begin
MB := MetabaseClass.Active;
Report := MB.ItemById("Report").Bind As IPrxReport;
Doc := Report.Sheets.FindByName("Document") As IPrxDocument;
DocObjects := Doc.DocumentObjects;
//...
//Selection of object identifiers by any attribute
//...
IdArray := New ArrayList.Create;
For i := 0 To DocObjects.Count - 1 Do
DocObject := DocObjects.Item(i);
If <Object selection condition> Then
//Save identifier to dynamic array
IdArray.Add(DocObject.Id);
End If;
End For;
//...
//Work with selected objects
//...
For i := 0 To IdArray.Count - 1 Do
DocObject := DocObjects.ItemById(IdArray.Item(i));
//...
End For;
End Sub UserProc;
The specified example shows in general how to get a collection of objects, select required object by any attribute and work with it further.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.ForeCollections;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
Doc: IPrxDocument;
DocObjects: IPrxDocumentObjects;
DocObject: IPrxDocumentObject;
i: Integer;
IdArray: IArrayList = New ArrayListClass();
Begin
MB := Params.Metabase;
Report := MB.ItemById["Report"].Bind() As IPrxReport;
Doc := Report.Sheets.FindByName("Document") As IPrxDocument;
DocObjects := Doc.DocumentObjects;
//...
//Selection of object identifiers by any attribute
//...
For i := 0 To DocObjects.Count - 1 Do
DocObject := DocObjects.Item[i];
If <Object selection condition> Then
//Save identifier to dynamic array
IdArray.Add(DocObject.Id);
End If;
End For;
//...
//Work with selected objects
//...
For i := 0 To IdArray.Count - 1 Do
DocObject := DocObjects.ItemById(IdArray.Item[i] As Integer);
//...
End For;
End Sub;
See also: