Insert new data in tableview. tableview.height doesn't change?

Hi. What I am trying to do is like a chat/message system. When new message is added, the tableview inserts the new message and scrolls up.

My problem now is that after I insert the new message in the tableview, the tableview’s height doesn’t change.

What I did is below:

1> list all old messages in tableview. (data is stored in ‘myList’ var)

2> create new message, 

3> add new message in ‘myList’.

3> tableview:removeAllRows()

4> tableview:insertNewData using ‘myList’.

5> tableview:scrollToY(y = 0-tableView.height …)

The problem now is in (5) tableView.height doesn’t change.

Also, is there a function that can scroll to the very bottom of the tableview? Currently, I am using (5) as listed above. 

Your tableView.height won’t change. Its the value of how tall you want it to be on screen.  When you create the tableView and in the creator you say:  height = 200,   then it will be 200 points high.  When you add more records than will show in the space, it will allow the user to scroll.  Think of height and width as defining the window size but the curtains behind the window are usually much bigger than the window but from outside the house you can only see the part that’s in the window.

For your other question see:   scrollToIndex()

https://docs.coronalabs.com/api/type/TableViewWidget/scrollToIndex.html

Rob

Thanks very much Rob. You always solved the problem !!!

Your tableView.height won’t change. Its the value of how tall you want it to be on screen.  When you create the tableView and in the creator you say:  height = 200,   then it will be 200 points high.  When you add more records than will show in the space, it will allow the user to scroll.  Think of height and width as defining the window size but the curtains behind the window are usually much bigger than the window but from outside the house you can only see the part that’s in the window.

For your other question see:   scrollToIndex()

https://docs.coronalabs.com/api/type/TableViewWidget/scrollToIndex.html

Rob

Thanks very much Rob. You always solved the problem !!!