Referencing a single datagrid cell
bobs at twft.com
Tue Feb 1 17:45:43 EST 2011
I am still having fits doing what I want. Perhaps in the past I have not described it very well, so I am going to try a different approach.
What I need is to access the value in a single cell of a data grid and change it. For instance I would like to do something like:
set the value of column 1 of row 1 of myDatagrid to "test". Better yet, although I know this is wishful thinking, set the 1:1 of myDataGrid to "test". Or how about, set the 1:1 to 1:3 of myDataGrid to "test1" & tab & "test2" & tab & "test3"? That was the kind of API I envisioned for a table object. I know that is simplistic, but I am not getting what I expect to get when I use the existing datagrid API.
I have really tried to understand the API but I am at a total loss. I don't want to work with arrays here, I want to work with the indexes that the API returns. The closest I can get is to get and set the dgDataOfIndex but those are arrays. I don't want to change the whole line. I don't want to have to put the whole line back together when I only want to change the one value in the one column in the one row. Is this even possible?
If not I understand, but it sure oughta be don't you think? Permit me a small rant. Shouldn't a table object work kind of like a spreadsheet, where I can reference a row and a column and get/set a value? This is really what I need. Knowing the internal array structure has not helped me.
I have gotten the dgDataOfIndex for a data grid, modified the first element in the array, set the dgDataOfIndex and then used DataGrid Helper to show me the contents of the data grid. The array is IDENTICAL to the one I get if I manually edit the values, but if I do it using code the datagrid appears empty, and refreshing the datagrid does not help.
So I guess until there is a method of simple row:column referencing of datagrids, I am going to revert to using the dgText. Thank GOD and thank Trevor for this, or for me data grids would be unusable.
ps. Thanks Zryip for all the help, but it appears your methods call things in the parent script that I cannot see or access (that may be a good thing) and so I cannot see what they are doing and why. I need to see code happen to understand it.
More information about the Use-livecode