Hi Guys
I am trying to build a datagrid that creates the total amount of lines that is displayed in a particular field. For instance if 127 is displayed in the field then 127 lines needs to be created in the datarid table whilst adding line numbers to each line in the 'Line Number' collumn of the datagrid. There will be 3 other collumns to the datagrid but these need to be left blank allowing users to be able to click in each cell and enter data manually.
I have just started working with Datagrids and have gone through the tutorials but none can teach me how to do the above.
Can anyone help with this?
Thanks
Daniel
add lines and line numbers to Datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: add lines and line numbers to Datagrid
Hi Daniel,
so you want to create NEW data for an empty datagrid with a user defined number of lines, right?
Well, "the dgtext of grp "datagrid" is in fact nothing else but a TAB and CR delimited list,
so creating this is unbelievable easy
In my example here, I presume that the "linenumber" column is the FIRST column in your grid.
You are talking about three other columns, so I thing you have a total of four columns in your datagrid.
then you could do this (out of my head, not tested!).
The parameter "thenumberoflines" will be the number that your user entered (or whatever...)
Best
Klaus
so you want to create NEW data for an empty datagrid with a user defined number of lines, right?
Well, "the dgtext of grp "datagrid" is in fact nothing else but a TAB and CR delimited list,
so creating this is unbelievable easy

In my example here, I presume that the "linenumber" column is the FIRST column in your grid.
You are talking about three other columns, so I thing you have a total of four columns in your datagrid.
then you could do this (out of my head, not tested!).
The parameter "thenumberoflines" will be the number that your user entered (or whatever...)
Code: Select all
command createLinesInDataGrid thenumberoflines
## We create the data in a repeat loop, go figure :-)
repeat with i = 1 to thenumberoflines
## Now we create the number for the first column and EMPTY entries for the other columns
put i & TAB & TAB & TAB & CR after tNewData
end repeat
## Get rid of last CR
delete char - 1 of tNewData
## that's all, now "put" the new data into your datagrid
set the dgtext of group "you datagrid name here" to tNewData
end createLinesInDataGrid
Klaus
Re: add lines and line numbers to Datagrid
Brilliant thank you Klaus.
If a user was to enter some data into a cell in the 2nd collumn and they wanted the same data to be entered into the next 20 lines of that collumn, would they be able to copy the data and then highlight all cells in that collumn for the next 20 lines and then paste?
Obviously you can do this 1 at a time but that's very time consuming. I kind of want my datagrid to work like Excel if you know what I mean!
If a user was to enter some data into a cell in the 2nd collumn and they wanted the same data to be entered into the next 20 lines of that collumn, would they be able to copy the data and then highlight all cells in that collumn for the next 20 lines and then paste?
Obviously you can do this 1 at a time but that's very time consuming. I kind of want my datagrid to work like Excel if you know what I mean!
Re: add lines and line numbers to Datagrid
Hi Daniel,
sounds like my script did in fact work!
I am afraid you can only edit ONE "cell" at a time manually.
Of course you can do this via script.
Best
Klaus
sounds like my script did in fact work!

I am afraid you can only edit ONE "cell" at a time manually.
Of course you can do this via script.
Best
Klaus