Printing multiple records without a data grid?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Printing multiple records without a data grid?
Hi Guys,
I've got a data grid which contains multiple records. I've had to invoke the scrollbar as there are lots of records, more than the datagrid can display. This all works ok for data entry (although I havent quite got formatting(bold/italics) to work right yet...), but I now need to print all those records out complete and I don't think I should be using the data grid for this as the rows are limited (I dont want a scroll bar).
Does anyone have a useful tutorial or a sample stack I can look at to figure out how I can achieve this.
If I was working with php, I would put all my records in a variable called $records and then use a foreach loop within a table and loop through the array, display the items from the array in its own <td> tag. Each record would be wrapped in a<tr> tag. Is there a neat way of doing this in LC? Bear in mind the data in my cells seem to have different number of lines of text in one record.
Im pretty certain you would use a foreach loop in LC, but I think is the formatting part of it that I also need to get right.
Hope the above kinda makes sense. Thanks as always
Jalz
I've got a data grid which contains multiple records. I've had to invoke the scrollbar as there are lots of records, more than the datagrid can display. This all works ok for data entry (although I havent quite got formatting(bold/italics) to work right yet...), but I now need to print all those records out complete and I don't think I should be using the data grid for this as the rows are limited (I dont want a scroll bar).
Does anyone have a useful tutorial or a sample stack I can look at to figure out how I can achieve this.
If I was working with php, I would put all my records in a variable called $records and then use a foreach loop within a table and loop through the array, display the items from the array in its own <td> tag. Each record would be wrapped in a<tr> tag. Is there a neat way of doing this in LC? Bear in mind the data in my cells seem to have different number of lines of text in one record.
Im pretty certain you would use a foreach loop in LC, but I think is the formatting part of it that I also need to get right.
Hope the above kinda makes sense. Thanks as always
Jalz
Re: Printing multiple records without a data grid?
You outline the solution... yourself !jalz wrote:If I was working with php, I would put all my records in a variable called $records and then use a foreach loop within a table and loop through the array, display the items from the array in its own <td> tag. Each record would be wrapped in a<tr> tag. Is there a neat way of doing this in LC? Bear in mind the data in my cells seem to have different number of lines of text in one record.

Take out the content of your DG, put it into a var... and then do what you want (loop, format, print) !
You just have to remember : datagrid use TAB as column delimiter and CR as row delimiter.
so for instance :
Code: Select all
put the DgText of grp "mydatagrid" into tVar
set itemdelimiter to tab
repeat for each line tLine in tVar
answer item 1 of tLine
answer item 2 of tLine
end repeat
Code: Select all
put the DGData of grp "mydatagrid" into tArray
Re: Printing multiple records without a data grid?
Thanks Bangkok,
Cant wait to give it a go when I am at home.I presume I can surround each row with a border or an alternative background color.
I'll have to experiment, see what is 'easily' possible.
Jalz
Cant wait to give it a go when I am at home.I presume I can surround each row with a border or an alternative background color.
I'll have to experiment, see what is 'easily' possible.
Jalz
Re: Printing multiple records without a data grid?
It's me again, I understand the concept thanks to bangkok of how to get the data out of my dg, what I cant seem to get my head around is how to get my fields to repeat on a layout. I know I can remove all the data out of the dg and place it in a large text field, but I would like to have some borders around the fields etc.
Can someone please look at my stack and tell me how I can clone those fields and repeat them on my layout to create my invoice like report. Im guessing that I need to group the three controls and create a repeating custom control. Am I on the right lines?
Thanking all in advance.
Jalz
Can someone please look at my stack and tell me how I can clone those fields and repeat them on my layout to create my invoice like report. Im guessing that I need to group the three controls and create a repeating custom control. Am I on the right lines?
Thanking all in advance.
Jalz
- Attachments
-
- repeatfields.livecode.zip
- (6.37 KiB) Downloaded 190 times
-
- repeatfields.livecode.zip
- (6.37 KiB) Downloaded 171 times
Re: Printing multiple records without a data grid?
You can set up the template field the way you want and then create new fields on the fly, and each will have the properties of the template. Then you'd place the text into the new field, and align it with the one above it. It's fiddly but it works. Loop through each line of your text, creating and adjusting the fields as you go. If you need help scripting that, let us know.
But is much easier to just set the hGrid of the field to true, which will place dividing lines between each paragraph, though the spacing isn't always ideal. You can change the color of the hGrid to whatever you want.
But is much easier to just set the hGrid of the field to true, which will place dividing lines between each paragraph, though the spacing isn't always ideal. You can change the color of the hGrid to whatever you want.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Printing multiple records without a data grid?
Hi,
I have a created 3 label fields called Title1, Firstname1, Surname1. I have grouped these 3 fields and given the group name "myFields". Im trying to loop through my data and place the data into the 3 fields
I get the following error on the first set the text… execution error at line 5 (Chunk: source is not a container), char 57
Can someone tell me how I can alter values in label field using my group name "myFields" please. my code is below.
Thanks
Jalz
I have a created 3 label fields called Title1, Firstname1, Surname1. I have grouped these 3 fields and given the group name "myFields". Im trying to loop through my data and place the data into the 3 fields
I get the following error on the first set the text… execution error at line 5 (Chunk: source is not a container), char 57
Can someone tell me how I can alter values in label field using my group name "myFields" please. my code is below.
Thanks
Jalz
Code: Select all
on mouseUp
put the DgText of grp "Datagrid 1" into tVar
set itemdelimiter to tab
repeat for each line tLine in tVar
set the text of field "Title1" to item 1 of tLine of group "myFields"
set the text of field "Firstname1" to item 2 of tLine of group "myFields"
set the text of field "Surname1" to item 3 of tLine of group "myFields"
end repeat
end mouseUp
Re: Printing multiple records without a data grid?
When you use "repeat for each", the variable contains the actual value of whatever you are parsing. In this case, tLine contains the text of a line in tVar. It isn't a line reference like "line 1", it's the text of line 1. So in this case, all you need is this:
set the text of field "Title1" to item 1 of tLine
set the text of field "Firstname1" to item 2 of tLine
set the text of field "Surname1" to item 3 of tLine
This is where using the debugger is extremely handy. Set a breakpoint right before the repeat starts and step through the code. It will still error at the same place, but right before that happens you would be able to see the value of tLine in the variables at the bottom of the script editor -- and that would clear it up right away. You could do that now before you fix it, just to see how valuable the debugger is.
To set a breakpoint, click in the left-hand gray margin (next to the line numbers) at the line where you want the debugger to stop.
set the text of field "Title1" to item 1 of tLine
set the text of field "Firstname1" to item 2 of tLine
set the text of field "Surname1" to item 3 of tLine
This is where using the debugger is extremely handy. Set a breakpoint right before the repeat starts and step through the code. It will still error at the same place, but right before that happens you would be able to see the value of tLine in the variables at the bottom of the script editor -- and that would clear it up right away. You could do that now before you fix it, just to see how valuable the debugger is.
To set a breakpoint, click in the left-hand gray margin (next to the line numbers) at the line where you want the debugger to stop.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Printing multiple records without a data grid?
Hi Jacque,
Thanks, I know the code below works as I originally started off this way before I started grouping. The thing is I have grouped the fields because I find this the most efficient way to clone the fields on my layout, replacing the group name of the cloned fields to myFields2 and inserting in another row of data in the cloned fields. Is there a way I can reference Title1 of a specific group?
However
Thanks, I know the code below works as I originally started off this way before I started grouping. The thing is I have grouped the fields because I find this the most efficient way to clone the fields on my layout, replacing the group name of the cloned fields to myFields2 and inserting in another row of data in the cloned fields. Is there a way I can reference Title1 of a specific group?
Code: Select all
set the text of field "Title1" to item 1 of tLine
set the text of field "Firstname1" to item 2 of tLine
set the text of field "Surname1" to item 3 of tLine
Re: Printing multiple records without a data grid?
Code: Select all
Is there a way I can reference Title1 of a specific group?
set the text of field "Title1" of grp <whatever > to...
If you're adding text as you clone each group then you can use "last group" as the group identifier. Otherwise you'll either need to identify it by a name or number.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com