|
| 1 | +--- |
| 2 | +id: version-2.4.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 | +## Methods |
| 16 | + |
| 17 | +### exportData(format: string, options?: ExportDataOptions): Promise\<string> |
| 18 | +Exports a file that contains the object's data, and returns a URL to the file. |
| 19 | + |
| 20 | +`format` defines the format of the data output file. |
| 21 | +Supported formats: |
| 22 | + - `"XLSX"` |
| 23 | + - `"CSV"` |
| 24 | + - `"TSV"` |
| 25 | + |
| 26 | +`options` is an [`ExportDataOptions`](ExportDataOptions.md) bundle that modifies properties of the exported data file. |
| 27 | + |
| 28 | +If no `options` parameter is supplied, the data will be exported using the default option values. |
| 29 | + |
| 30 | +### exportPDF(options?: ExportPDFOptions): Promise\<string> |
| 31 | + |
| 32 | +Exports a PDF of the report object and returns a URL to the PDF document. |
| 33 | + |
| 34 | +`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. |
| 35 | + |
| 36 | +If no `options` parameter is supplied, the report is exported using the default options values. |
| 37 | + |
| 38 | +### refreshData(): void |
| 39 | + |
| 40 | +Refreshes the data for the report object that is controlled by the |
| 41 | +`ObjectHandle`. |
| 42 | + |
| 43 | +### getData(options?: Object): ReportObjectResultData[] |
| 44 | + |
| 45 | +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. |
| 46 | + |
| 47 | +#### Arguments |
| 48 | + |
| 49 | +`options` is an optional options bundle for customizing the returned data. The following options are supported: |
| 50 | + |
| 51 | +- `formatData` specifies the format of the returned data. |
| 52 | + - `true` returns all formatted data. |
| 53 | + - `false` returns all unformatted data. |
| 54 | + - `"datesOnly"` `default` returns SAS date values as formatted data and returns all other values as unformatted data. |
| 55 | + |
| 56 | +#### Return value |
| 57 | + |
| 58 | +Returns an array of [`ReportObjectResultData`](ReportObjectResultData.md) objects, where each object is associated with one data set. |
| 59 | + |
| 60 | +### getSelectedData(options?: Object): ReportObjectResultData[] |
| 61 | + |
| 62 | +Returns a user's selection data from the report object. Returns an empty array if the object has no selections. |
| 63 | + |
| 64 | +#### Arguments |
| 65 | + |
| 66 | +`options` is an optional options bundle for customizing the returned data. The following options are supported: |
| 67 | + |
| 68 | +- `formatData` specifies the format of the returned data. |
| 69 | + - `true` returns all formatted data. |
| 70 | + - `false` returns all unformatted data. |
| 71 | + - `"datesOnly"` `default` returns SAS date values as formatted data and returns all other values as unformatted data. |
| 72 | + |
| 73 | +#### Return value |
| 74 | + |
| 75 | +Returns an array of [`ReportObjectResultData`](ReportObjectResultData.md) objects, where each object is associated with one data set. |
| 76 | + |
| 77 | +For user selection data, the ReportObjectResultData property `columns` will never include values for `usage`, `aggregation`, or `format`. |
| 78 | + |
| 79 | +### addEventListener(eventType: string, listener: (event: Object) => void) |
| 80 | + |
| 81 | +Adds an event listener to the `ObjectHandle` to call the supplied listener when the specified event occurs. |
| 82 | + |
| 83 | +#### Arguments |
| 84 | + |
| 85 | +`eventType` is a string that represents the event type to listen for. These event types are supported: |
| 86 | +- `"selectionChanged"` for listening for selection changes in the object. |
| 87 | + |
| 88 | +`listener` is an event listener callback function. When the event occurs, `listener` is called and passed an event object containing the following properties: |
| 89 | +- `type` is a string that matches the event type. |
| 90 | +- `target` refers to the ObjectHandle that the event occurred on. |
| 91 | + |
| 92 | +### removeEventListener(eventType: string, listener: (event: Object) => void) |
| 93 | + |
| 94 | +Removes the previously registered event listener from the `ObjectHandle`. |
0 commit comments