Categories | Question details Back To List | ||
Adding rows in dhtmlgrid Hi, I am using dhtmlxTreeGrid_v14_Pro version. I would like to better understand how to increment the rowid when adding a row... I have an empty (two calendar columns) "grid.xml" that contains: <?xml version="1.0" encoding="UTF-8"?> <rows><row id="1"><cell></cell><cell></cell></row></rows> I am using the following script <script language="JavaScript" type="text/javascript"> mygrid = new dhtmlXGridObject('gridbox'); mygrid.setImagePath("imgs/"); mygrid.setHeader("From,To"); mygrid.setInitWidths("108,108"); mygrid.setColAlign("center,center"); mygrid.setColTypes("calendar,calendar"); mygrid.setColumnColor("white,white"); mygrid.setColSorting("date,date"); mygrid.enableMultiselect("true"); mygrid.clearAll(); mygrid.init(); mygrid.loadXML("grid.xml"); </script> and I am trying to add rows with: mygrid.addRow(new Date().valueOf(),[(new Date()),(new Date())],mygrid.getRowIndex(mygrid.getSelectedId())) Using form integration and after adding two rows, I get gridbox_1193410360765_0 gridbox_1193410360765_1 gridbox_1_0 gridbox_1_1 for the corresponding grid cells. But, instead I would like to get gridbox_1_0 gridbox_1_1 gridbox_2_0 gridbox_2_1 and so on (for additional rows). I know I have to replace "new Date().valueOf()" with something else. Please tell what to do... Answer posted on Oct 29, 2007 06:53 If you want to have rowID equal to rowIndex you can use mygrid.addRow(mygrid.getRowsCount()+1,[(new Date()),(new Date())],mygrid.getRowIndex(mygrid.getSelectedId())) such command will create ID equal to current count of row ( please beware that if you deleting rows in grid - it possible to create situation when proposed above ID will be not unique ) |