在客户端删除UltraWebGrid的所有行

有时需要在客户端上删除某个UltraWebGrid中所有的行,而如果按照帮助文件中例子的方法来操作的话,是无法删除行的。经询问NetAdvantage工程师,给出一个能用的例子。

//帮助中的例子,不可用
  1. function DeleteRow ( ) {
  2. // Row deletion needs to be allowed
  3. igtbl_getGridById ( "UltraWebGrid1" ). AllowDelete= 1;
  4. // Get the first row in the grid
  5. var row=igtbl_getRowById ( "UltraWebGrid1r_0" );
  6. // Delete the first row in the grid
  7. igtbl_deleteRow ( "UltraWebGrid1", "UltraWebGrid1r_0" );
  8. // Create a counter for the row id
  9. var cnt= 0;
  10. // Create a loop, if the row has a next sibling then we need to delete it
  11. while (row. NextSibling != null ) //在这步,row.NextSibling总是为Undefined类型。以致不能删除行
  12. {
  13. // Increment the counter for the next rowID
  14. cnt+= 1;
  15. // Get the row current row using the name of the grid and the row
  16. // number from our counter so we can check it for a sibling
  17. row=igtbl_getRowById ( "UltraWebGrid1r_"+cnt )
  18. // Finally delete that row,
  19. igtbl_deleteRow ( "UltraWebGrid1", "UltraWebGrid1r_"+cnt );
  20. }
  21. }
//可用的例子
  1. function DeleteRow ( ) {
  2. var grid = igtbl_getGridById ( "<%= uwgList.ClientID % >" );
  3. var grna=document. getElementById ( "<%=uwgList.ClientID %>" ). name;
  4. var rowsLenght = grid. Rows. length;
  5. for ( var i = 0; i < rows. Lenght; i++ ) {
  6. igtbl_deleteRow (grna,grna+ "_r_"+i );
  7. }
  8. }

你可能感兴趣的:(grid)