[]
        
(Showing Draft Content)

PROPERTY

PROPERTY function parses an object by property. The user can specify the property path to return the value of object.

PROPERTY function provides support for parsing the return object to a valid property value. For example, this function is useful in MultiColumn Picker.

Syntax

PROPERTY(data_expression, property_path)

Arguments

This function has the following arguments:

Argument

Description

data_expression

Refers to an object data, and accepts cell reference, the value of which is object or the result of object function.

property_path

Refers to the property path in the object.

Remarks

The PROPERTY function will throw #N/A error if the data_expression is not an object. The function will also throw #N/A error if the property_path cannot be found in the object.

Data Types

Accepts string data.

Examples

$(document).ready(function () {
    // initializing Spread
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
    // get the activesheet
    var sheet = spread.getActiveSheet();
    // DataSource is array
    let dataSource = [
        {
            "NAME": "James Smith",
            "POSITION": "AVP",
            "OFFICE": "Fox Studios",
            "EXTN": 71,
            "START_DATE": '3/08/2008',
            "JOINING_YEAR": 2008
        }
    ];
    let colInfos = [
        { name: "NAME", displayName: "NAME", size: "2*" },
        { name: "POSITION", displayName: "POSITION", size: "*" },
        { name: "OFFICE", size: "*" },
        { name: "EXTN", size: "*" },
        { name: "START_DATE", size: 100 },
        { name: "JOINING_YEAR", size: 100 }
    ];
    // create style
    var style = new GC.Spread.Sheets.Style();
    style.cellButtons = [
        {
            imageType: GC.Spread.Sheets.ButtonImageType.dropdown,
            command: "openMultiColumn",
            useButtonStyle: true,
        }
    ];
    style.dropDowns = [
        {
            type: GC.Spread.Sheets.DropDownType.multiColumn,
            option: {
                width: 600,
                height: 150,
                dataSource: dataSource,
                bindingInfos: colInfos
            }
        }
    ];
    // set style's formatter
    style.formatter = '=PROPERTY(@, "OFFICE")';
    // set style
    sheet.setStyle(0, 1, style);
    // set text
    sheet.setText(0, 0, "DataSource is array, return data parsed to the value of property 'OFFICE'.");
    // set wordwrap
    sheet.getCell(0, 0).wordWrap(true);
    sheet.getCell(0, 1).wordWrap(true);
    // set column width
    sheet.setColumnWidth(0, 200);
    sheet.setColumnWidth(1, 400);
    // set row height
    sheet.setRowHeight(0, 70);
});

Dot Operator

SpreadJS provides the dot operator “.” to use as a shorthand for the PROPERTY formula function. It helps to simplify the PROPERTY function and makes the code simpler to read.

It requires two values, the left value as the object and the right value as the field of the object. You can also surround the right value with quotes if it has illegal characters.

Note: The dot "." operator is case sensitive, the same as the PROPERTY formula function.

Example

Comparing the use of both PROPERTY formula and the dot operator.

  • Property formula function: "=PROPERTY(G10,"User.Address.Home")"

  • Dot operator: "=G10.User.Address.Home"

For the dot operator, the left value is the object or the reference of the object and the right value is the field of the object.