PDA

View Full Version : Number of rows currently visible in grid



jasewell
6 May 2013, 10:04 AM
Does Ext.grid.View have an easy way to get an answer to the question "Given the current layout of this grid, how many rows are there room to display?"

Thanks in advance.

slemmon
7 May 2013, 9:42 PM
It's possible I'm over-simplifying here, but first thought that comes to mind is view.getHeight() / 21.

jasewell
8 May 2013, 6:20 AM
It's possible I'm over-simplifying here, but first thought that comes to mind is view.getHeight() / 21.
I could do something like that, yeah. We make a lot of use of the grouping and groupingsummary features, which would complicate things a bit, but it's still a solvable problem. I hate to do something like that and then find out that there's a built in method that already does what I need, though, hence the question. So it sounds like the answer to the original question is "No"?

slemmon
8 May 2013, 10:10 AM
I don't believe there is, no. I did some looking last night in the API to make sure I wasn't missing something, but just to clarify, you were asking "how many rows are there room to display". Are you instead looking more for "how many rows (not including grouping rows) are currently displayed"?

jasewell
8 May 2013, 11:53 AM
I don't believe there is, no. I did some looking last night in the API to make sure I wasn't missing something, but just to clarify, you were asking "how many rows are there room to display". Are you instead looking more for "how many rows (not including grouping rows) are currently displayed"?
I think that's an equivalent question, provided we don't count rows you'd have to scroll down to see as "displayed".

slemmon
8 May 2013, 1:38 PM
I was thinking of the questions as different in that if you weren't grouping or didn't have variable-height rows you could just divide view height by row height and know what could be in the view, but if the view was rendered with rows and had several grouped headers with custom css in a grouping tpl then the number of actual rows visible in the view -vs- the number of possible rows in a view would be different.

While there's not a convenience method for grabbing the rows in view you could loop through the view's nodes and get their region and see if the region intersects with the view's region to see if the node is currently visible.

jasewell
8 May 2013, 1:48 PM
While there's not a convenience method for grabbing the rows in view you could loop through the view's nodes and get their region and see if the region intersects with the view's region to see if the node is currently visible.
I hadn't thought of that, thanks!