Calculate number of rows in a DataGrid
Terence Heaford
t.heaford at btinternet.com
Wed Nov 19 15:11:55 EST 2014
> On 19 Nov 2014, at 19:38, Trevor DeVore <lists at mangomultimedia.com> wrote:
>
> Ah, so you want to know how many rows could be drawn in the visible area of
> the data grid. This should work:
>
> put the dgWorkingRect of group "MyDataGrid" into theVisibleRect
> put item 4 of theVisibleRect - item 2 of theVisibleRect into
> theVisibleHeight
> put theVisibleHeight / the dgProps["row height"] of group "MyDataGrid" into
> theNumberOfVisibleRows
Thanks Trevor,
I have modified it slightly by using trunc with the final division to get a whole number of rows.
What is all this for?
I have a table that is using the large data method.
I select the the data from that table and pass it to this, the table in question, that is being used to print a report in table format.
This table is adjusted according to the paper size and I need to display only the data for one page at a time to enable the batch printing process of LC, therefore I need to know the number of whole rows that will fill the paper size, then adjust the height of the DG again.
In addition I adjust the widths of the columns using percentages passed in according to whether the print is landscape or portrait.
It all seems to work quite well and beats creating a reporting stack.
My next step is to add top/bottom margins for titles etc.
The only issue I am having is the artefacts I have reported as a bug when I print preview in OS X Yosemite. The alternate colour row is showing vertical lines in the cells as per this example screen grab
https://dl.dropboxusercontent.com/u/98788898/LiveCode/Screen%20Shot%202014-11-17%20at%2007.40.52.png <https://dl.dropboxusercontent.com/u/98788898/LiveCode/Screen%20Shot%202014-11-17%20at%2007.40.52.png>
All the best and thanks again
Terry
More information about the use-livecode
mailing list