4
votes

NSTableView is what I am using to display millions of data, which I can not get in response due to time out.

So what I decided to get response in pages say 1-100 then 101-200 etc.

So my problem starts here, how can I know that I have reached to the end of tableView or the cell is visible say 100th row?

I dont want to implement Load More.. kind of button etc.

After this I will send a new response with new range.


Here is what I have tried so far:

Tried to track the scrollView and get next set of data by a service call.

*It works with old mouse but it failed with swipe.

1
oops sorry, guess I misunderstood your questionEugene
You shouldn't worry about what row you have reached. When you implement data source you'll get asked for the proper rows, according to what rows are visible. Is enough that you put them in some cache. For example you get asked for row 50, if the row is in the cache you just return it's value, otherwise you fetch rows from 0 to 100 ([N-50,N+50]) and put them in the cache.Ramy Al Zuhouri
@RamyAlZuhouri: I dont want unneccessary fetching of data. I want data to be fetched only when last row is visible. See this very similar to Facebook and all other sites. Also I dont want to implement Load More.. kind of button etcAnoop Vaidya
So your goal is a sort of “infinite scrolling” UI, where new rows are brought in to the model upon reaching the end of the view?Peter Hosey
@AnoopVaidya Any suggestions for stackoverflow.com/questions/21795083/…user88975

1 Answers

4
votes

Maybe you can determine the last visible row after a scroll, I've a subclassed NSTableView with this method

@interface MyTableView : NSTableView
- (NSInteger)lastVisibleRow;
@end


@implementation MyTableView
    - (NSInteger)lastVisibleRow {
        NSRect bounds = [[self superview] bounds];
        bounds.origin.y += bounds.size.height - 1;
        return [self rowAtPoint:bounds.origin];
    }

@end