Is it possible to copy copy the data in a datagrid into another datagrid? Is the coding simple to acheive this? Not all the data but say for instance I want to copy rows 15-20 from a datagrid and to paste to another datagrid on a a different card.
Your help is most appreciated!
copy data from datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: copy data from datagrid
Hi.
Get the dgText, extract lines 15-20, and set the dgtext of the other datagrid to the new data.
Get the dgText, extract lines 15-20, and set the dgtext of the other datagrid to the new data.
Re: copy data from datagrid
Thanks for this mate but I'm pretty new to working with datagrids - could you help me out with the code?
Re: copy data from datagrid
Do you have a dataGrid running with data already in it? And another datagrid to receive the information? If so, in a button script, say:
on mouseUp
set the dgText of grp "targetDatagrid" to line 15 to 20 of the dgText of grp "sourceDatagrid"
end mouseup
Datagrids are complex in that they are composed of many different fields, graphics, scrollbars, you name it. But there are a few very transparent properties that make dealing with them very simple, at least at a basic level. The dgText is one of those, which you can get and set. It consists of tab and return delimited data that directly populates the datagrid.
Is this clear? If we were dealing with simple fields, would you have more comfort with the idea? In a field, you would do essentially the same thing, but rather:
on mouseUp
put line 15 to 20 of fld "sourceField" into fld "targetField"
end mouseup
Works the same, the difference being that fields are containers, where you can "put" data, whereas dataGrids are not, so you have to get and set properties. Once you get used to the difference, it is no longer an issue. For example, scripts also are not containers, they are properties of an object. You cannot change a script by putting data into them, as in a field. Their contents are accessable by getting and setting. Here is a simple hack for an existing button script:
on mouseUp
get the script of button "foo"
put return & "destroyComputer" after line 1 of it
set the script of button "foo" to it
end mouseUp
Write back if this is not clear.
Craig Newman
on mouseUp
set the dgText of grp "targetDatagrid" to line 15 to 20 of the dgText of grp "sourceDatagrid"
end mouseup
Datagrids are complex in that they are composed of many different fields, graphics, scrollbars, you name it. But there are a few very transparent properties that make dealing with them very simple, at least at a basic level. The dgText is one of those, which you can get and set. It consists of tab and return delimited data that directly populates the datagrid.
Is this clear? If we were dealing with simple fields, would you have more comfort with the idea? In a field, you would do essentially the same thing, but rather:
on mouseUp
put line 15 to 20 of fld "sourceField" into fld "targetField"
end mouseup
Works the same, the difference being that fields are containers, where you can "put" data, whereas dataGrids are not, so you have to get and set properties. Once you get used to the difference, it is no longer an issue. For example, scripts also are not containers, they are properties of an object. You cannot change a script by putting data into them, as in a field. Their contents are accessable by getting and setting. Here is a simple hack for an existing button script:
on mouseUp
get the script of button "foo"
put return & "destroyComputer" after line 1 of it
set the script of button "foo" to it
end mouseUp
Write back if this is not clear.
Craig Newman