DataGrid LayoutControl

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

Post Reply
garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

DataGrid LayoutControl

Post by garyth123 » Fri Jun 21, 2013 5:10 pm

What do the items in on LayoutControl mean?

eg

put the rect of field "Name" of me into theFieldRect
put item 1 to 4 of pControlRect into item 1 to 4 of theFieldRect
set the rect of field "Name" of me to theFieldRect

put the rect of field "Stadium" of me into theFieldRect
put item 1 to 4 of pControlRect into item 1 to 4 of theFieldRect
set the rect of field "Stadium" of me to theFieldRect

is giving me what can be seen in the attached png. I thought this would be correct for a fixed height layout. Clearly there is something I don't understand. Can anyone help?
Attachments
layout.png

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

Re: DataGrid LayoutControl

Post by Klaus » Fri Jun 21, 2013 5:30 pm

Hi Gary,

I'm not sure, but I think this (pControlRect) describes the available total space in your row template
and is meant to be used if your layout changes by user interaction in a datagrid of type FORM like
clicking a button "More options..." and you change/expand your layout dynamically.

But no matter what this means, you are setting the rect of your two fields to the same rect! 8-)

This looks like a datagrid of type TABLE.
Why not ust use a couple of columns?
Or why not just leave the "layoutcontrol" handler empty?


Best

Klaus

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: DataGrid LayoutControl

Post by garyth123 » Sat Jun 22, 2013 9:19 am

Hi Klaus,

Well you are quite right and that is why my text is overlaid as in the png.

It is in fact a Form.

I have two fields set up in the template. No matter what I try I cannot get them to appear as you'd expect. I get one or either of them at a time, or they overlap.

Are the items of pControlRect an x, y (of the top left corner of the field), and a horizontal width, and vertical depth?

Here is another attempt and an image of what it produces:

put the rect of field "Name" of me into theFieldRect
put item 1 to 4 of pControlRect into item 1 to 4 of theFieldRect
set the rect of field "Name" of me to theFieldRect

put the rect of field "Stadium" of me into theFieldRect
put item 4 of pControlRect into item 2 of theFieldRect
put item 3 to 4 of pControlRect into item 3 to 4 of theFieldRect
set the rect of field "Stadium" of me to theFieldRect
Attachments
layout1.png

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

Re: DataGrid LayoutControl

Post by Klaus » Sat Jun 22, 2013 11:14 am

Hi Gary,

sorry, I still hjave no idea what you are actually trying to achieve!? :-)

Please tell me:
1. What does your "Row template" look like.
2. How should the final layout look like.
3. If 1. is correctly setup already, do you really need the "layoutcontrol" handler? 8-)


Best

Klaus

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: DataGrid LayoutControl

Post by garyth123 » Sat Jun 22, 2013 12:04 pm

Hi Klaus,

I am following Academy tutorial 50 so am expecting two rows alternately coloured, but where each row is the same height.

Attached is a png of my row template, and an image of what I get if I comment out the lines in the layoutControl handler. As you can see I only get one row. I would have expected the template to take care of the layout of the two rows. I can get the other row (on its own) by fiddling with the layoutControl items to pControlRect. Or I can get the two rows overlapping, but what I want is one row reading Team name: Id and another row reading Stadium name.

It is very frustrating.
Attachments
layout nothing in layoutcontrol.png
templatelayout.png

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

Re: DataGrid LayoutControl

Post by Klaus » Sat Jun 22, 2013 12:24 pm

Hi Gary,

hmm, it definitively SHOULD look like in your template WITHOUT using the "layoutcontrol" handler!

Did you un-/check "Fixed control height" for the datagrid?
Is that value "Row height" set to the heigth of the template group containing these fields?


Best

Klaus

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: DataGrid LayoutControl

Post by garyth123 » Sat Jun 22, 2013 12:44 pm

Hi Klaus,

Thanks that has solved the problem.

Gary

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

Re: DataGrid LayoutControl

Post by Klaus » Sat Jun 22, 2013 1:44 pm

AH, great! :-D

Post Reply