Getting Started with DataGrid and another datagrid form
Bob Sneidar
bobsneidar at iotecdigital.com
Mon Aug 6 12:22:26 EDT 2018
The template is like the group editor. In fact it may actually BE the group editor. The behavior script determines what to do when a row is drawn.
I think the thing to understand about datagrids, table or forms, is that for each array element in the data (itself an array) the template is "cloned". Each row is a "clone" of the template. But for forms, the behavior does not know what you want to do when the rows are created. For instance, you may want to color negative numbers in red, or surround them with parenthesis. You may have a button that needs to be hilited or not depending on the value for that control. Perhaps you have a field that can contain multiple lines of text, and you need to set the row height for each row based upon the formattedHeight of that field. Or maybe show and hide objects etc.
The beauty of a form datagrid is that how each individual row gets drawn is entirely under your own programmatical control. A table datagrid is simply like a spreadsheet with fixed row heights and no support for graphics or other controls.
BTW I kinda cheated and made a way to have checkboxes for a table style datagrid. I simply had a group with checkboxes overlaying a "dummy" column in the datagrid. When I queried for data I put something like:
SELECT '' AS checkmark, '' AS checkmarkvalue, * FROM customers
This put two empty strings in my array data (I use sqlYoga so I get arrays back instead of cursors, but the idea is the same). I only defined a column for "checkmark", but NOT for "checkmarkvalue". This allowed me to have a blank column to overlay the checkboxes on, and a hidden column to hold the checkmarkvalue for each row in the datagrid data.
Then when I populated the datagrid, I hid all the checkboxes then showed each checkbox control based upon how much data was being displayed. Of course, you have to account for scrolling, so that can be tricky, but it was a poor man's way of adding checkboxes to a table datagrid. Others could probably come up with a more elegant solution.
Bob S
> On Aug 5, 2018, at 10:03 , Sannyasin Brahmanathaswami via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> I slowly studying as much as we can on the datagrid,and "digging" in it with an first attempt to build a form.
>
> One thing is not clear to me.
>
> 1) Have the WYSIG panel to build the datagrid form.
>
> 2) why then do we have, in the Behavior Script this handler?
>
> Isn't the layout already pre-determined in the template?
More information about the use-livecode
mailing list