SpreadJS 14
Formula Reference / Formula Functions / Other Functions / PROPERTY
In This Topic
    PROPERTY
    In This Topic

    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

    JavaScript
    Copy Code
    <script>
            $(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);
            });
        </script>
    

    See Also

    HLOOKUP | LOOKUP