|
| 1 | +--- |
| 2 | +id: version-2.6.0-ObjectHandle |
| 3 | +title: ObjectHandle |
| 4 | +original_id: ObjectHandle |
| 5 | +--- |
| 6 | + |
| 7 | +An `ObjectHandle` is used to perform actions on a single object in an open |
| 8 | +report. An object's handle can be obtained using the `getObjectHandle` method |
| 9 | +on a [`ReportHandle`](ReportHandle.md). |
| 10 | + |
| 11 | +When a report element is assigned new attribute values or removed from the DOM, |
| 12 | +any `ObjectHandles` obtained from that element are invalidated and should be |
| 13 | +discarded. |
| 14 | + |
| 15 | +## Properties |
| 16 | + |
| 17 | +### readyState: string |
| 18 | +The ready state of the report object. When this value changes, a `readyStateChanged` event is fired on the ObjectHandle. |
| 19 | + |
| 20 | +This value can be one of the following: |
| 21 | + - `"contentLoading"` when the report object is still loading its content. |
| 22 | + - `"complete"` when the report object has finished loading. |
| 23 | + - `"error"` when the report object encountered an error and could not load. |
| 24 | + |
| 25 | +## Methods |
| 26 | + |
| 27 | +### exportData(format: string, options?: ExportDataOptions): Promise\<string> |
| 28 | +Exports a file that contains the object's data, and returns a URL to the file. |
| 29 | + |
| 30 | +`format` defines the format of the data output file. |
| 31 | +Supported formats: |
| 32 | + - `"XLSX"` |
| 33 | + - `"CSV"` |
| 34 | + - `"TSV"` |
| 35 | + |
| 36 | +`options` is an [`ExportDataOptions`](ExportDataOptions.md) bundle that modifies properties of the exported data file. |
| 37 | + |
| 38 | +If no `options` parameter is supplied, the data will be exported using the default option values. |
| 39 | + |
| 40 | +### exportPDF(options?: ExportPDFOptions): Promise\<string> |
| 41 | + |
| 42 | +Exports a PDF of the report object and returns a URL to the PDF document. |
| 43 | + |
| 44 | +`options` is an [`ExportPDFOptions`](ExportPDFOptions.md) that controls the format of the exported PDF document. The option `includedReportObjects` does not apply when exporting a report object. |
| 45 | + |
| 46 | +If no `options` parameter is supplied, the report is exported using the default options values. |
| 47 | + |
| 48 | +### refreshData(): void |
| 49 | + |
| 50 | +Refreshes the data for the report object that is controlled by the |
| 51 | +`ObjectHandle`. |
| 52 | + |
| 53 | +### getData(options?: Object): ReportObjectResultData[] |
| 54 | + |
| 55 | +Returns all of the data from the report object. This data matches what appears in the report object, including any filters that have been applied. |
| 56 | + |
| 57 | +#### Arguments |
| 58 | + |
| 59 | +`options` is an optional options bundle for customizing the returned data. The following options are supported: |
| 60 | + |
| 61 | +- `formatData` specifies the format of the returned data. |
| 62 | + - `true` returns all formatted data. |
| 63 | + - `false` returns all unformatted data. |
| 64 | + - `"datesOnly"` `default` returns SAS date values as formatted data and returns all other values as unformatted data. |
| 65 | + |
| 66 | +#### Return value |
| 67 | + |
| 68 | +Returns an array of [`ReportObjectResultData`](ReportObjectResultData.md) objects, where each object is associated with one data set. |
| 69 | + |
| 70 | +### getSelectedData(options?: Object): ReportObjectResultData[] |
| 71 | + |
| 72 | +Returns a user's selection data from the report object. Returns an empty array if the object has no selections. |
| 73 | + |
| 74 | +#### Arguments |
| 75 | + |
| 76 | +`options` is an optional options bundle for customizing the returned data. The following options are supported: |
| 77 | + |
| 78 | +- `formatData` specifies the format of the returned data. |
| 79 | + - `true` returns all formatted data. |
| 80 | + - `false` returns all unformatted data. |
| 81 | + - `"datesOnly"` `default` returns SAS date values as formatted data and returns all other values as unformatted data. |
| 82 | + |
| 83 | +#### Return value |
| 84 | + |
| 85 | +Returns an array of [`ReportObjectResultData`](ReportObjectResultData.md) objects, where each object is associated with one data set. |
| 86 | + |
| 87 | +For user selection data, the ReportObjectResultData property `columns` will never include values for `usage`, `aggregation`, or `format`. |
| 88 | + |
| 89 | +### addEventListener(eventType: string, listener: (event: Object) => void) |
| 90 | + |
| 91 | +Adds an event listener to the `ObjectHandle` to call the supplied listener when the specified event occurs. |
| 92 | + |
| 93 | +#### Arguments |
| 94 | + |
| 95 | +`eventType` is a string that represents the event type to listen for. These event types are supported: |
| 96 | +- `"selectionChanged"` for listening for selection changes in the object. |
| 97 | +- `"readyStateChanged"` for listening to changes on the `readyState` property. |
| 98 | + |
| 99 | +`listener` is an event listener callback function. When the event occurs, `listener` is called and passed an event object containing the following properties: |
| 100 | +- `type` is a string that matches the event type. |
| 101 | +- `target` refers to the ObjectHandle that the event occurred on. |
| 102 | + |
| 103 | +### removeEventListener(eventType: string, listener: (event: Object) => void) |
| 104 | + |
| 105 | +Removes the previously registered event listener from the `ObjectHandle`. |
0 commit comments