2
votes

I'm developing a component for UI5. In the metadata->properties part I want to define a property of the type Integer. If I set the data type by "markerSize" : {type:"integer",defaultValue:"25"} (or any other variation like Integer, Number, number) I get the errormessage that 50 (the current value) can't be accessed by "in". Changing the data type to string is working. In the examples from SAP I can only find "string" and "sap.ui.core.CSSSize" as datatype. How can I define numeric values? Is there a list of supported datatypes an their correct definition?

KR, Nico

1

1 Answers

4
votes

If you use int as data type, then your defaultValue should not be a string (although it causes no error...). Your problem is that instead of "integer" you have to use "int". so please try this here:

{ type:"int",defaultValue: 25 }

That should work. This code worked for me:

<script>

    sap.ui.core.Control.extend("my.Control", {
        metadata : {
            properties : {
                "text" : "string",
                "size" : {type: "int", defaultValue: 500 }
            },
        },

        renderer : function(oRm, oControl) {  
            oRm.write("<div>size = "+oControl.getSize()+"</div>") 
        }

    });

    var myControl = new my.Control({text:"Hello"});
    myControl.placeAt("content");        
</script>    

<body class='sapUiBody'>
    <div id='content'></div>
</body>

I hope that helps.