Referencing a single datagrid cell

Bob Sneidar bobs at twft.com
Tue Feb 1 17:29:43 CST 2011


Ok Peter helped me understand the GetDataOfIndex/SetDataOfIndex functions. I think when I read, "- Retrieves the internal array for key pIndex of the internal array in the data grid..." I just assumed that the returned value would always be an array. I see now that if you reference a column name for the second argument you get a value instead. 

Bob


On Feb 1, 2011, at 3:14 PM, zryip theSlug wrote:

> On Tue, Feb 1, 2011 at 11:45 PM, Bob Sneidar <bobs at twft.com> wrote:
>> Hi all.
>> 
>> 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.
>> 
>> <end_rant>
> 
> Hi Bob,
> 
> First of all have a look to these lessons:
> 
> http://lessons.runrev.com/spaces/lessons/manuals/datagrid/lessons/7313-How-Do-I-Get-Data-Associated-With-a-Row-or-Column-
> 
> and to the
> SetDataOfIndex and SetDataOfLine commands, in the API documentation
> 
>> 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.
> 
> I planned to create a new step by step tutorial about drag & drop
> technics in datagrids. A kind of compilation of all the experiments I
> done on this subject but this time with details explanation. Will
> write it at soon as I have more time for.
> 
> 
> Best regards,
> -- 
> -Zryip TheSlug- wish you the best! 8)
> http://www.aslugontheroad.co.cc
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list