[]
        
(Showing Draft Content)

DataObject Cell

The DataObject cell type allows a cell to display structured object data and extract object properties directly into adjacent cells.

When a cell value is an object and the cell type is set to GC.Spread.Sheets.CellTypes.DataObject, a built-in button image appears in the cell.

Clicking the button displays a dropdown list of object properties. Selecting a property writes its value into the adjacent empty cell on the right. This operation supports Undo.

dataObject.gif

Note: If the adjacent cell is merged or part of a table, the extraction fails and triggers an InvalidOperation event with the message: "Cannot insert data".

image

The DataObject cell type supports a format string to control how the object is displayed in the cell. The format can use the PROPERTY function or the @. dot operator.

Example:

// Retrieve object data
sheet.setFormula(1, 1,
  '=FILTERJSON(WEBSERVICE("https://demodata.grapecity.com/northwind/api/v1/Products/1"))'
);

// Apply DataObject cell type with display format
var cellType = new GC.Spread.Sheets.CellTypes.DataObject(
  '=@.productName & " " & @.unitPrice'
);

sheet.setCellType(1, 1, cellType);

The DataObject cell type can also be configured in the SpreadJS Designer:

Home tab → Styles group → Cell Editors → Cell Type → Data Object

image

Enter a valid format string in the Format field to control how object properties are displayed.

image

The format must be valid; otherwise, it will not be applied.