有时需要在客户端上删除某个UltraWebGrid中所有的行,而如果按照帮助文件中例子的方法来操作的话,是无法删除行的。经询问NetAdvantage工程师,给出一个能用的例子。
//帮助中的例子,不可用
-
function DeleteRow ( ) {
-
// Row deletion needs to be allowed
-
igtbl_getGridById ( "UltraWebGrid1" ). AllowDelete= 1;
-
// Get the first row in the grid
-
var row=igtbl_getRowById ( "UltraWebGrid1r_0" );
-
// Delete the first row in the grid
-
igtbl_deleteRow ( "UltraWebGrid1", "UltraWebGrid1r_0" );
-
// Create a counter for the row id
-
var cnt= 0;
-
// Create a loop, if the row has a next sibling then we need to delete it
-
while (row. NextSibling != null ) //在这步,row.NextSibling总是为Undefined类型。以致不能删除行
-
{
-
// Increment the counter for the next rowID
-
cnt+= 1;
-
// Get the row current row using the name of the grid and the row
-
// number from our counter so we can check it for a sibling
-
row=igtbl_getRowById ( "UltraWebGrid1r_"+cnt )
-
// Finally delete that row,
-
igtbl_deleteRow ( "UltraWebGrid1", "UltraWebGrid1r_"+cnt );
-
}
-
}
//可用的例子
-
function DeleteRow ( ) {
-
var grid = igtbl_getGridById ( "<%= uwgList.ClientID % >" );
-
var grna=document. getElementById ( "<%=uwgList.ClientID %>" ). name;
-
var rowsLenght = grid. Rows. length;
-
for ( var i = 0; i < rows. Lenght; i++ ) {
-
igtbl_deleteRow (grna,grna+ "_r_"+i );
-
}
-
}