Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to get number of rows in text area when I paste something in SAPUI5?


       In my application I am using text area as columns in a table. In that I am getting data in the text area cells  from another page.

To count the number of rows entered in the text area I am using below code and placing this count value as dynamic in text area.

var count = 0;

                for(var i=0; i<dataName.length; i++){

                if(dataName[i] !== undefined){

                    if(count < dataName[i].split(/\r|\r\n|\n/).length){

                                count = dataName[i].split(/\r|\r\n|\n/).length;




oTV = new sap.ui.commons.TextArea({

                      width : '100%',

                      rows : count,

                       value : dataName[int2-2],

                      editable : false,


Every thing is working fine when I press enter to go the next line.

But the problem is when I enter any data without using enter key or when I paste some data into that text area I am getting count value only one

I even used   count = dataName[i].split("\n").length; still I am getting count value "1". It's taking all the code entered in text area as one line.

How can we count the no of rows in text area without pressing enter key?

Pleased help me to solve this.



Not what you were looking for? View more on this topic or Ask a question