Scroll to selected row in CellTable - gwt

I have a GWT CellTable contained in a ScrollPanel. The CellTable is set to use a SingleSelectionModel<T> I am programatically setting the selected row, which is working fine. However, the cell table isn't scrolled to the selected row. Is there a way I can both select the row and scroll so the selected row is visible?

Andrei was on the right track, but setScrollTop(int) gives the number of pixels to scroll, not the index to scroll to. What works is:
myTable.getRowElement(index).scrollIntoView();
this adjusts the scrolling so that the element is in view. Note that if your table scrolls horizontally, scrollIntoView() will scroll it all the way to the right in an attempt to show all of the cell. I didn't want this behavior, so I subsequently called:
myScrollViewThatContainsCellTable.scrollToLeft();

Try
myTable.getRowElement(index).setScrollTop(0);
where index is the index of a selected row.

Related

Scrollable Table View - scroll when needed

I have a scrollable tableView and I want to add tooltip some of these cells. For this, I made the necessary checks and kept the cellPaths as the row and section of necessary cells to which tooltips will be added.
My problem starts here: if I try to add a tooltip to the cells currently displayed on the screen there is no problem, but if I try to add a tooltip to an off-screen cell I don't know what to do.
I will use scrollRowAtIndexPath at some point, but I couldn't check if the cell with the required indexPath is off-screen.
I tried checking by comparing the cell.frame with the frame of the visible screen but it can be an easier approach.

UITableView Grouped table border issue

I am creating a grouped table with two sections.In the first section i have 5 cells and in the second section i have two buttons in the lass cell of it.
I have created labels and buttons on each of the cells in the first section and the labels are populated dynamically by the values selected in the previous screen.
Everything works fine as expected,except the borders of the table view gets ruined,it looks like half drawn and incomplete.When i make the table view to scroll up and when its back in the original position,the top borders are spoiled and when i scroll to the bottom the lower borders of the group gets affected making them incomplete.
I am setting the label's and button's attributes in each of cell after initializing them in the viewDidLoad method.
Please suggest me an idea to solve this issue.
Thank you one and all
I am setting the label's and button's attributes in each of cell after
initializing them in the viewDidLoad method.
This is incorrect. You should save the texts for the labels & buttons in a model class & set them in the cellForRowAtIndexPath: method. As, you are not doing this in the aforementioned method, your cell is redrawn when you scroll and the texts are nullified.

UITableView add row at top

I have a Uitableview with loading mode like that,
When user scroll to item 5 it'll auto load 10 item and add in the top of label.
My problem is when add like that, current cell move down 10 item, it's bad look.
Can we add cell at top UITableView but current cell not move up or down until user scroll.
What you could do is insert your rows, then use scrollToRowAtIndexPath:atScrollPosition:animated: method to scroll to the row you would like to display. More info here.
Just posted an answer with code snippets here
Keep uitableview static when inserting rows at the top
Basically:
Save the scroll offset where you would have called beginUpdate:.
In place of calls to InsertCell you add the cell's height to the saved offset.
Where you would have called endUpdate:, call reloadData, then scroll by the saved offset with NO animation.

Show selected row always while scrolling UITableView?

Let's say we have a UITableView with some 100 rows, we select a row and after that we scroll the UITableView. The selected row is also scrolled top or bottom direction but I want the selected row to be always visible to the user while scrolling the table. Is it possible ?? please help me out which sample code..(it is same like twitter scrolling)
If you want this, you'll have to write a completely custom tableview from scratch (which I believe was done for Twitter.app). There's no way to do that with the built-in tableview.

Row selection when dragging over a UITableView with scrolling disabled

If one were to create a standard grouped table view consisting of two rows and then touch down on the first row, the cell would highlight. If one were to then drag one's finger down, the selection of the row cancels, and the table view begins to move with the drag.
Imagine the same situation, but with table view scrolling disabled via tableView.scrollEnabled = NO. Now, when one has selected a row and begins to drag, the row deselects and the table remains static.
I have two questions:
How can I ensure the row isn't deselected when one selects and drags within the confines of the row?
When one drags from the first row to the second row, how can I ensure that the first row is deselected and the second row becomes selected?
For an example of this functionality in action, open the Clock app and select the Alarm tab bar item. Tap the top right plus button and a modal view will appear presenting four rows. Tap down on the first row, drag onto the second, and you'll see the selection move across rows while the table itself remains static. How is this achieved?
On a tableView with scrollEnabled = NO when you touch on any cell you get a didHighlightRowAtIndexPath, and when you start to drag you get didUnhighlightRowAtIndexPath (even if you stay within the cell). The cell is not selected or deselected when you drag, and no further cells highlight/unhighlight on that touch.
There is a shouldHighlighRowAtIndexPath method that is called, where you can decide if the touch should highlight the row or not, but not a shouldUnhighlight method.
If the 'flash' of the highlight/unhighlight bothers you, you could use the shouldHighlight method to just return NO. Or you could return NO if a cell is selected.