on 05-30-2016 8:41 AM
Hello experts,
I am very new to the Fiori. I wanted to know the code for removing the leading zeros in the line item of the table in XML view.
I know it can be achieved using JS formatter function, but would like to achieve using expression binding as I am not much familiar of this concept..
For example
00005 -> 5
00001 -> 1
Regards,
Salil B
The field which contains the value with the leading zeroes - if you are sure that this field will always contain a string value (for e.g. 00001234) the just call the parseInt() function and pass the value to this function as parseInt('00001234'); the result will be 1234.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Saurabh,
I am aware of this as mentioned using Javascript as mentioned below, but wanted to achieve it using the XML expression binding. Let me know if you are aware of how to do it without going with JS.
stripLeadingZeros : function(v) {
if (typeof v === "string") {
return parseInt(v, 10)
}
return v
},
Regards,
Salil B
Achieving this in XML view you can use a constraint:
<ObjectIdentifier text = "{path : 'CUSTOMER_ID', type : 'sap.ui.model.odata.type.String', constraints : {isDigitSequence : true, maxLength : 10 }}" title="{NAME}"/>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.