1

Currently I am using angular-ui/ui-scroll to populate the list of items in the table.

Is there a way I can get the list of all visible items that are being rendered in the ui using ui-scroll?

I was using adapter.topVisible and adapter.bottomVisible to get the top visible item and bottom visible item. But not sure about getting all the items in between them

1 Answer 1

1

Get the indexOf the top item and get the indexOf bottom item, and then that should give you all the visible item indexes (between top and bottom).

Sign up to request clarification or add additional context in comments.

6 Comments

Hi, thanks for your reply. Can you please be more specific in getting all the visible item indexes. Not sure if I followed you correctly. Any piece of code that illustrates your answer would be nice to have. Thank you
I've not worked with ui-scroll so I can't help you with code unless you make me a plunker. If you're saying you have a top and bottom items, and you have the array of items then you need to get the index of the top item and index of the bottom item, and everything in between should be what's visible. Assuming they are in order as visible.
Your example isn't very good because you're not storing anything you get. So I don't know how you're supposed to get data. From the way I see it, you have 4 very important information available, topItem, topScope, topElement, top.$index, you can use this value and query the back-end for all items that fall within the top and bottom. And there you have the visible items. Does that make sense? Just call the datasource.get() method to return you from index=top and count = bottom-top. Alternatively you have the topElement and use jquery to fetch all elements until you hit bottomElement.
Yep I really like the first idea you suggested make an api call with index = top and count = bottom-up. The reason being i am not storing is, ui-scroll maintains buffer to get the items internally. Not sure if there is a way to access buffer and loop over it instead of making an api call ?
I don't see any exposed API in the library that allows access to this information. Making an api call is fine, you can attempt temporarily caching as well.you might even be able to extend the scroller and introduce a get visible items directive, all it needs is the dataSource and adapter information.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.