You can export the rows and nesting-column values shown in a ViewModel grid as tab-separated text, for example to paste the grid into Excel or send its content to another Turnkey session.
Purpose
GetGridAsTabSepData creates one large string from a grid rooted at a ViewModel column. The string uses tab-separated values, also called TSV. Use it when the grid data is already defined in the ViewModel and you need that displayed collection as text rather than as individual objects.
For example, if a grid is rooted in the ViewModel column SearchResults, the operator can create tab-separated text from the objects in that collection and the values in its nesting columns.
Prerequisites
Before you use this operator:
- Create a ViewModel column that is a collection and use it as the grid root. In this example, the collection column is named
SearchResults. - Add the nesting columns whose values you want to include in the exported grid data.
- Place the operator in the OCL expression or action that needs the resulting string.
The ViewModel grid definition determines which collection and nesting-column values are available to the operator. Review the grid before using the exported value: a value not represented by the grid's nesting columns is not part of the described export.
Export a grid
- Identify the ViewModel column that roots the grid. For example:
SearchResults. - Configure the grid's nesting columns with the values the receiving user or system needs. For example, a search-result row may contain a name, an identifier, and a status.
- Use
GetGridAsTabSepDatafor that grid root in the relevant OCL logic and retain the returned string. - Use the string where it is needed. You can present it for a user to copy into Excel, or pass it to RemoteTurnkeySetStringValue when sending it to another system through Remote Turnkey.
Example
Assume SearchResults is a grid collection with nesting columns for a result name, an identifier, and a status. The exported text represents the collection's rows as tab-separated values. Conceptually, two rows can look like this:
Northwind 1001 Active
Contoso 1002 Inactive
The tab characters separate values within each row. A spreadsheet application can use those separators to place the values in separate cells when the user pastes the text.
Use with Remote Turnkey
Use this operator when another system needs the grid contents as one string. A typical flow is:
- Build the grid in a ViewModel.
- Create the tab-separated string with
GetGridAsTabSepData. - Send the string with RemoteTurnkeySetStringValue.
- In the receiving session, retrieve a string value with RemoteTurnkeyGetStringValue if that is part of your integration flow.
Make the receiving system responsible for interpreting the tab-separated format. Test the complete flow with representative grid values before relying on it for an integration.
Considerations
- The operator is intended for a grid rooted in a ViewModel column, such as
SearchResults. - The result is one large string. Consider the size of the grid and the capacity of the receiving destination when you export many rows.
- Tab-separated text is useful for spreadsheet paste and text-based interchange. If your consumer requires XML or JSON, use the format-oriented operators described in ViewModelAsXml or ViewModelAsJSon instead.
