I currently have the following code:
Code: Select all
on mouseUp
lock screen
put empty into lineNo
put the dgHiLitedLines of group selectComponentGrid into rowNumbers
put the dgData of group selectComponentGrid into rows
repeat for each item rowNumber in rowNumbers
put rows[rowNumber] into row
log row["id"] && row["sku"]
dispatch "AddData" to group bomGrid of card inventoryItem of stack inventory with row
if lineNo is empty then
put the result into lineNo
end if
end repeat
# Set focus to the first new row's quantity field.
if lineNo is not empty then
put "quantity" into colName
dispatch "EditCellOfIndex" \
to group bomGrid on card "inventoryItem" of stack "inventory" \
with "quantity", lineNo
log "EditCellOfIndex result: " & the result
put false into firstTime
end if
unlock screen
close this stack
end mouseUp
The sub-stack contains a DataGrid. The user select any number rows in the DataGrid and then clicks OK.
The code above adds a new row to a DataGrid on a card in the main stack for each row selected in the DataGrid in the sub-stack and then opens a field in first added row for editing.
My question is this:
Should the bulk of this logic be moved to the main stack's card and the OK button's script changed to just send a message to, or call a function of that card?
TIA,
Dave