如何删除datagrid

时间:2015-05-25 10:42:43

标签: livecode

如何删除datagrid中的行。我正在使用以下代码并且它不起作用(前两行正在工作,第三行不起作用)我如何更改代码。

put the dgHilitedLines of group "DGP"  into theLine
   answer theLine
   DeleteLine theLine

4 个答案:

答案 0 :(得分:1)

如果在datagrid外部执行此操作,则需要使用Dispatch命令删除DataGrid中的行。例如。使用数据网格外的按钮。

on mouseUp
   put the dgHilitedLines of group "DGP"  into theLine
   answer "The selected line var is : " & theLine
   dispatch "deleteline" to group "DGP" with theLine  
   put the result into tDeleteresult
   if tDeleteresult is not empty 
   then 
      answer "There has been a problem deleting the line with message: "&tDeleteresult
   else
      answer "Line Deleted"
   end if
end mouseUp

答案 1 :(得分:0)

您是否尝试使用索引而不是行?

put the dgHilitedIndex of me into theIndex 
DeleteIndex theIndex

该行始终是当前的显示顺序,例如

A = 1

B = 2

C = 3

因此,如果你删除第2行,下一行C将成为第2行。这通常是一个问题。

删除行后:

A = 1

C = 2

另一方面,索引在填充数据网格时分配,并且对于一行保持相同,无论您如何排序。这样,您始终可以识别该行

使用索引:

A = 1

B = 2

C = 3

删除第2行后:

A = 1

C = 3

答案 2 :(得分:0)

作为一种惯例,我总是明确地做这类事情。 LC本身内的工具和分析比DG本身更容易获得和强大。

总的来说:

  get the dgData of group "yourDG"
  delete line whatever of it
  set the dgData of group "yourDG" to it
克雷格纽曼

答案 3 :(得分:0)

与Mr.CoolLion一样的答案更为简洁:

put the dgHilitedLines of group "DataGrid" into theLineNo
dispatch "deleteline" to group "DataGrid" with  theLineNo