Can't delete Row in Grid

Hello

I have a big problem inside my Grid as i’m not able to delete rows on button click. Grid should open with a specified number of editable rows. There should be also the possibility to add 1 row at the last position (works) and to delete the last position. I added “myGrid.deleteRow();” but happens nothing.

GRID

Grid[1] = new dhtmlXGridObject('gridbox');
Grid[1].setImagePath("../../../dhtmlx/Grid/codebase/imgs/");
Grid[1].setHeader("<span style='padding-left:70px'>Seriennummer</span>");
Grid[1].attachHeader("#text_filter");
Grid[1].setInitWidths("236");
Grid[1].setColAlign("left");		 
Grid[1].setColTypes("ed");
Grid[1].enableEditEvents(true, false, false);
Grid[1].enableRowsHover(true, 'grid_hover');
Grid[1].setSkin("modern");
Grid[1].init();	
Grid[1].enableUndoRedo();
Grid[1].enableAlterCss("rows_even", "rows_uneven");
Grid[1].loadXML("../../../dhtmlx/Data/XML/grid.php?id=26&menge=<?php echo $menge; ?>");	

GRID.PHP

if($_GET['id'] == "26") {
   header("Content-type: text/xml");
   echo('<?xml version="1.0" encoding="ISO-8859-1"?>'); 
   echo '<rows>';
   
   for($i = 1; $i <= $_GET['menge']; $i++) {
      echo ("<row id='".$i."'>");
	  print("<cell><![CDATA[]]></cell>");
	  print("</row>");
   }

   echo '</rows>';
}

ADD ROW

ToolBar.attachEvent("onClick", function(id) {
   switch (id) {
      case "plus": Grid[1].addRow(Grid[1].getRowsNum()+1,[""]); break;
   }
}

DELETE ROW

ToolBar.attachEvent("onClick", function(id) {
   switch (id) {
      case "minus": Grid[1].deleteRow(Grid[1].getRowId(Grid[1].getRowsNum())); break;
      // how cann i delete the last row in Grid ?
   }
}

Would be reeeaaaally really nice if someone can help me with this. Where’s my mistake ?

Best regards
Oliver

Do you have twice toolbar.attachEvent on your code or was it just to give a sample?

Also to get the last row you would have to use getRowsNum() - 1 because of 0 index.

Hope this is of any help…

Damn … I have just 1 ToolBar but i forgot the “0” Index :blush:

Thank you … now everything’s fine

Please, try to use:

Grid[1].deleteRow(Grid[1].getRowId(Grid[1].getRowsNum()-1))

as index is a zero-based number

:blush: souu slouu…