Page 1 of 1

Datagrid help

Posted: Fri Nov 11, 2011 2:44 pm
by bsouthuk
Hi

I am trying to update all cells within a column in my datagrid but I cant work out how. I currently have the following code:

Code: Select all

put field "ID6" into theDataA["DealerContactID"]

put 2 into theLineNo

repeat with i = 1 to theLineNo
 dispatch "AddData" to group "MobileNumbersDataGrid" with theDataA, theLineNo
end repeat

However, this actually ADDS 2 new rows but I only want to EDIT the cells within the column of the existing rows. I have the put 2 into theLineNo code but also want it so that it updates ALL the cells within the column not just 2.

Can anyone help with this?

Thanks

Daniel

Re: Datagrid help

Posted: Fri Nov 11, 2011 3:25 pm
by Klaus
Hi Daniel,

as the name suggests and as clearly described in the DataGrid docs, "AddData" will indeed ADD a new line to your datagrid.
Doing so in a repeat loop "with 1 to 2" will result in TWO NEW lines :shock:
8)

I am still not sure what exactly you want to do?
And please post the rest of your script, if there is any.


Best

Klaus

Re: Datagrid help

Posted: Fri Nov 11, 2011 3:29 pm
by bsouthuk
If for instance there are 20 rows of data in my datagrid, I want to be able to click a button and for the date to appear in each row of a particular column.

Thanks for your help

Re: Datagrid help

Posted: Fri Nov 11, 2011 4:31 pm
by Klaus
Hi Daniel,

I think you need to loop through the complete datagrid array and change the value of your "DealerContactID" field if I understand you correctly.

Something like this (out of my head, NOT tested!)

Code: Select all

...
## Get the complete data
put the DGData of grp "MobileNumbersDataGrid" into tArray
put field "ID6" into tDealerContactID

## Now update every entry of DealerContactID
repeat for each key tKey in tArray
  put tDealerContactID into tArray[tKey]["DealerContactID"]
end repeat

## Set the data of the datagrid back to the now modified array
set the DGData of grp "MobileNumbersDataGrid" to tArray
...
Best

Klaus

Re: Datagrid help

Posted: Fri Nov 11, 2011 4:45 pm
by bsouthuk
Works perfectly - thank you Klaus!

Re: Datagrid help

Posted: Fri Nov 11, 2011 4:46 pm
by Klaus
Grrrrrreat! :D