如何以编程方式编辑实时代码数据网格中任意行中的字段?

How can I edit a field in an arbitrary row in a livecode datagrid programatically?

我正在开发一个 LiveCode 项目,该项目显示带有 DataGrid 的模式 table。

如果用户在 DataGrid 中选择一行或多行并单击“确定”按钮,则所选行将复制到另一个堆栈中的另一个 DataGrid table。

我想在另一个堆栈中的第一个复制行中打开一个编辑字段。

我找到了 EditFieldText 命令,但无法弄清楚要提供什么作为第一个参数 (pField)。

我假设其他参数(pIndex 和 pKey)分别是 DataGrid 行索引和列名。

这是我的确定按钮中的代码:

on mouseUp
   lock screen
   put the dgHiLitedLines of group selectComponentGrid into rowNumbers
   put the dgData of group selectComponentGrid into rows
   put true into firstTime
   repeat for each item rowNumber in rowNumbers
      put rows[rowNumber] into row 
      dispatch "AddData" to group bomGrid of card inventoryItem of stack inventory with row
      if firstTime is true then
         # Set focus to this row's quantity field.
         put "quantity" into colName
         put the result into lineNo -- the result contains the index of the new row
         send "EditCellOfIndex colName lineNo" to group bomGrid on card "inventoryItem" of stack "inventory"
         # At this point the result contains "no control exists for index column"
         put false into firstTime
      end if
      #end if
   end repeat
   unlock screen
   close this stack
end mouseUp

我花了几个小时阅读 LiveCode 文档和搜索。我找到了很多文章,但没有解释如何实际执行此操作。

我在 Mac OS X 10.11.6.

上使用 LiveCode 9.0.0-dp-4|Build 15003 社区版

编辑 2017-01-17 13:23: 我找到了 EditCellOfIndex 命令,根据我发现的各种示例修改了我的代码以使用它,但也没有成功。 我更新了上面的代码以反映我所做的更改。

一切都与语法有关(我还在习惯 LiveCode 语法)。
我对 EditCellOfIndex 消息使用了错误的语法。

我还需要将发送消息移出循环,将行添加到另一个 DataGrid,因为下一次添加会关闭幻像编辑字段。

感谢 LiveCode 论坛上的 sritcp 语法捕获。 这是功能代码:

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
      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
   if lineNo is not empty then
      # Set focus to the first new row's quantity field.
      dispatch "EditCellOfIndex" \
            to group bomGrid on card "inventoryItem" of stack "inventory" \
            with "quantity", lineNo
   end if
   unlock screen
   close this stack
end mouseUp