DataGrids... and printing...

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

DataGrids... and printing...

Post by Traxgeek » Thu Oct 10, 2013 3:50 pm

Hi all,

I'm trying to print a data grid.

I can print the card that the DG resides on but... the number of rows in the DG is greater than the number of rows that can be displayed on any one card - so the DG v. scrollbar lets all the data (rows) be viewed via use of the scrollbar. Basic enough.

How would one display the DG from any particular row ? Say the card allows 7 rows to be visible at any one time. I'd like to :

-1- view rows 1-7 (that's pretty simple :wink: ! )
then view rows 8 to 14
then view rows 15 - 21
...etc etc... you get the idea ! (I van handle the repeat logic, it's the set the rownumber of the dg.... I can't seem to figure out)

-2- simply display the DG from (say) row 11 (in my case, to row 18)...

I've looked at various permutations of :
set the dgselectedline of control "dgMyDG" to nMyNumber and other similar stuff but... :? then, I looked at :
set the dgvScroll of group "dgMyDG" of card "crdMyCard" to (nDisplayFRomThisRow * nTheHeightOfEachRowInTheDG) - this works but, is there not a simpler way to say '... from Row 8... or similar ?

I then have two other issues, how to get the DGRow height (That's the Rect I guess but...)
And... most important...

If my DG is, say 18 rows long and the card can display 7 rows at a time, then rows 1 to 7 are OK, rows 8 to 14 are, similarly, OK... but I don't seem to be able to force a row to the top of the DG if it's within the last 7 (in my case) of the total available... I mean it doesn't seem possible to have a DG display blank spaces below it to fill in the 'missing' rows between 19 and 21. Or, another way, if I do the above, what I end up with is rows 1-7, then rows 8 to 14 then rows 11 to 18 displayed when the last 'should be' (for me and prettiness) row 15, row16, row17, row 18, blank, blank, blank. How would I get around this please ?

Any bright sparks / pointers please ?

Thanks a million.

Regards.
Last edited by Traxgeek on Thu Oct 10, 2013 4:10 pm, edited 3 times in total.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: DataGrids... and printing...

Post by Klaus » Thu Oct 10, 2013 4:01 pm

Hi Trax,

maybe:
...
dispatch "ScrollLineIntoView" to grp "Your datagrid here..." with 8
...
?

Will scroll the DG so line 8 is on top, you get the picture.

Hint!
Load the complete Datagrid PDF here: http://lessons.runrev.com/m/datagrid and read it as often as possible :D

That's what I did, but need to look up again every time I did not use a datagrid for more than a week, its TOO f*&%?#g complex :D


Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: DataGrids... and printing...

Post by Traxgeek » Thu Oct 10, 2013 4:13 pm

Aha - Klaus - you beat me to my edit and thanks, that's a huge help.

Are you also able to help with the display of the end of a DG ?...
If my DG is, say 18 rows long and the card can display 7 rows at a time, then rows 1 to 7 are OK, rows 8 to 14 are, similarly, OK... but I don't seem to be able to force a row to the top of the DG if it's within the last 7 (in my case) of the total available... I mean it doesn't seem possible to have a DG display blank spaces below it to fill in the 'missing' rows between 19 and 21. Or, another way, if I do the above, what I end up with is rows 1-7, then rows 8 to 14 then rows 11 to 18 displayed when the last 'should be' (for me and prettiness) row 15, row16, row17, row 18, blank, blank, blank.

Thanks a million. I'll go download the pdf (again, I think :oops: lost / can't find the last one )

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: DataGrids... and printing...

Post by Klaus » Thu Oct 10, 2013 4:23 pm

Hi Trax,
I mean it doesn't seem possible to have a DG display blank spaces below it to fill in the 'missing' rows between 19 and 21.
sure? :D

Just made a test with a fresh datagrid TABLE and could add blank lines at the end "ad lib"! 8)


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: DataGrids... and printing...

Post by dunbarx » Thu Oct 10, 2013 4:35 pm

Hi.

Klaus' idea of padding lines so that you have an integral number of "sevens" is likely the only way. No scrolling control (I think) could do what you sort of initially asked for, that is, to display lines 15-21 of an 18 line "field".

The only reason I am posting is that don't the last few empty padded lines show up when you print? I assume what you really want is to display a page with 7 lines, 7 lines and then 4 lines, but with those 4 lines shown as their own smaller block, not just the first four of a 7 line block filled in.

In which case there is still work to do...

Craig Newman

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: DataGrids... and printing...

Post by Traxgeek » Thu Oct 10, 2013 4:45 pm

Ah, the light is dawning...

I've always been a little crap as explaining myself... Never more so than now...

So, If I have a DG control that displays 7 rows on the card (necessitating a v scrollbar) and I have 18 entries/rows to display I have to manually add enough empty rows to the DG to make up for my lack of them ? Wow, that doesn't make sense even to me ! I'm useless at explaining - never could be a teacher ! What I'm trying to say is that it seems you can force the DG to display from a particular row as long as there are sufficient rows beneath the required row to fill the DG completely - hence my initial question.

So, as above, with 18 rows in a 7 row DG form, I can display rows 1-7, then rows 8 to 14 but have to add 3 blank rows to display rows 15 - 18 ; where rows 1, 8 and 15 are to be the top most rows in the DG each time.

Does that make sense ? If this is correct than I'm done / I see what's to be scripted and off I go... ;-)

Thanks Klaus.

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: DataGrids... and printing...

Post by Traxgeek » Thu Oct 10, 2013 4:48 pm

Aha - thanks Craig. Much more succinct (EDIT - Than me, I mean - Klaus' explanation was also perfectly clear) !

Agreed, and my thinking at the moment is simply to ;
-1- force the colours of the padded rows (the ones at the end of the display run) to be white / background colour

or

-2- to shorten my DG for the last display run. I'm guessing I could do this using the height item of the 'rect' multiplied by the number of rows remaining... ?

Make sense ? Or do you have a cunning plan ?

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: DataGrids... and printing...

Post by Traxgeek » Thu Oct 10, 2013 5:26 pm

So, I thought I wasn't too bad on DGs but...

How would one get a list of properties for the DG control please ?

I'm trying to ascertain the number of rows / lines in my DG (I can get it from the population script but... is there a property that returns this ?
I'm also trying to ascertain the row height of my DG (again, I have designed this so I could just use my designed value, but if I change my layout for any reason I will then have to remember to change my scripts so, the property would be useful.)

I'm sure they're all available but where please ? (Hopefully, this will help slow any future questions down a wee bit too - I come from VB (and others) but generally, all (? 90% anyway) of available properties for any control were itemised / listed in the control setup ui, so... I'm still finding out tons with LC... frustrating...)

Thanks a million guys.

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: DataGrids... and printing...

Post by Klaus » Thu Oct 10, 2013 5:39 pm

Hi Trax,

another approach could be:
1. Store the complete DGDATA of your datagrid in a custom property
2. Set the DGDATA to line 1 to 7 of the stored data
PRINT
3. Same for line 8 to 14
PRINT
4. then to the last remaining single line 15
PRINT
5. Set the DGDATA to the complete stored DGDATA
Et voila :D

You get the picture...

Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: DataGrids... and printing...

Post by Traxgeek » Thu Oct 10, 2013 6:01 pm

Hmmm... cunning !... Hadn't thought of anything as clever as that !

Still struggling with some basics though, how to get the number of lines/rows in my DG, how to get the height of a row of my DG and finally, how to override the odd/even line colouring...

Is there a list of properties for the DG ? I've downloaded the manual and... I'm sorry... but I'm no wiser (as to getting a list of available properties - at least then I can just try different ones to see what I get) ! :oops:

Thanks again. Much appreciated.

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: DataGrids... and printing...

Post by Traxgeek » Thu Oct 10, 2013 6:02 pm

Would 'dgProp[.....]' do it ?

EDIT 1 - Indeed it would for the Height : dgProp ["row height"] is the man ! :)
But... that was the result of guessing possible properties. eg : dgProp["number of rows'] doesn't work :(

and, if so, where would one get a list of the available properties ? Argh...

EDIT 2 - Aha - In the CustomProperties section of the Property Inspector for that DG control... :)
Hasn't helped with my getting the number of rows currently in the DG though :(

Thanks (again)...

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: DataGrids... and printing...

Post by Klaus » Thu Oct 10, 2013 6:16 pm

Traxgeek wrote:Hmmm... cunning !... Hadn't thought of anything as clever as that !
:D
Traxgeek wrote:Still struggling with some basics though, how to get the number of lines/rows in my DG
...
put the dgNumberOfLines of grp "Your datagrid here..." into tNumberOfLines
...
Traxgeek wrote:how to get the height of a row of my DG and finally,
...
put the dgProp[ "row height" ] of grp "Your datagrid here..." into tRowHeight
## Will only work if "fixed control height" is checked in the Inspector for your datagrid.
...
Traxgeek wrote:how to override the odd/even line colouring...
...
set the dgProp[ "alternate row colors" ] of grp "Your datagrid here..." to FALSE
...
Traxgeek wrote:Is there a list of properties for the DG ? I've downloaded the manual and... I'm sorry... but I'm no wiser (as to getting a list of available properties - at least then I can just try different ones to see what I get) !
Check section "10 API and Properties" in the PDF!


Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: DataGrids... and printing...

Post by Traxgeek » Thu Oct 10, 2013 6:20 pm

What can I say ?

As ever, 'fantastic stuff' Klaus !

I'm indebted (again) !

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: DataGrids... and printing...

Post by Klaus » Thu Oct 10, 2013 6:27 pm

Well, it's all in a day's work of a forum guru... :D

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: DataGrids... and printing...

Post by Traxgeek » Fri Oct 11, 2013 9:10 am

Hi, one more question please ?

If I want to override the row colour of a DG row (just for one (or more) specific row(s) within the full DG) how would I do that please ?

For example, to 'blank out' my padding rows OR say, in an accounts DG, I want to maintain the normal odd / even row colouring BUT, when I come across a -ve total, I'd like to change (override) the background colour of that whole row.

I have (I think) two issues (so I guess that's two questions ! :oops: - not just the one I said above !) :
-1- what property would I need to look at in order to override the 'normal' alternate row colour of any specific row ?
-2- where would I make that change (so that it occurs AFTER the DG has done its business of setting the row to the normal odd/even colouring sequence (i.e.. pointless effecting a change when the DG will then (after I'm finished) effect its own odd/even row colouring...) ?

Hope that makes sense.

Thanks a million.

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Post Reply