So might I suggest now is a great time to get away from using dgText? dgData
(an array) is a much better way of accessing the data in a datagrid. If you can
retrieve the data from your database as an array, then you only need to set the
dgData of the datagrid to that array. The form will be a numbered key followed
by the column name. Note this is not the column label, but the actual column
name.
I set up my datagrid content dynamically. What I do is I get a list of the
columns from the table first. SHOW COLUMNS <tablename>. The first column will
be the column names. set the dgData to empty first (or you will get an error on
the next step) Next delete the column names that you do not want displayed from
your list of columns. Then set the dgProp["columns"] to your list of columns.
(Also dgprop["column labels"] and dgProp["column widths"] if you like because
those will get reset when you set the dgProp["columns"]). Then set the dgData
to an array of the data from your query.
Note that only the columns whose names match the ones in your datagrid will be
displayed. You can use this to your advantage. Perhaps you only want to present
a subset of the table columns. The datagrid can still contain all of them,
effectively making the datagrid a kind of writeable pseudo-cursor complete with
the unique key needed in an update where clause. So rather than lots of queries
as the user interacts with the form, you can do one large query, and work with
the data locally.
Also (and forgive me if I keep pressing the point) but sqlYoga is a GREAT tool
for doing this sort of thing. Once you set up a database object and connection,
you can ask sqlYoga for all kinds of things, like a list of columns for a
table, or query data as text, records, a cursor or as an array. Data is
automagically escaped so you do not have to worry about that. All the gotchas
of working with SQL are handled for you. It's worth every penny I think. And
the arrays it returns from queries can go right into your datagrids!
Bob
On Jan 25, 2012, at 8:46 PM, Paul Looney wrote:
> Bob,
> Thank you.
> That was very helpful. The only key that had data was the record ID -
> explains why clicking on a line still opened the record viewer but nothing
> else was visible.
> Looking deeper.
> PL
>
> On Jan 25, 2012, at 5:36 PM, Bob Sneidar wrote:
>
>> put the dgData of group "<your data grid here>" into theDataA
>> put printKeys(theDataA)
>
> _______________________________________________
> use-livecode mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode