Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Kenneth Cho on Jan 02, 2009 21:03
open dhtmlx forum
add row

add row

when I add the new row, it adds the row that not in the last

could you help
thank you

<div id="gridbox" width="100%" height="400px" style="background-color:white;overflow:hidden;"></div>
<input type="button" value="Add row" onclick="mygrid.addRow((new Date()).valueOf(),['','','','',false],mygrid.getRowIndex(mygrid.getSelectedId()))" />

<script>
    function m_f2(id){
document.getElementById("a_1").innerHTML="Selected row: "+id;
}
    mygrid = new dhtmlXGridObject('gridbox');
    mygrid.setImagePath("js/grid/codebase/imgs/");
    mygrid.setHeader("a,b,c,d,e");
    mygrid.setInitWidths("393,100,100,100,120")
    mygrid.setColAlign("left,right,left,right,right");
    mygrid.setColTypes("ed,dyn,co,dyn,dyn");
    mygrid.setColSorting("str,int,str,int,int")
    mygrid.enableAlterCss("even","uneven");
    mygrid.enableMultiline(true);
    mygrid.enableAutoHeigth(true,"400");
    mygrid.init();
    
    mygrid.enableLightMouseNavigation(true)
    mygrid.setSkin("light")
    mygrid.loadXML("js/grid/newGrid.xml");
    mygrid.forEachRow(function(id){
            mygrid.cells(id,2).cell.className='not_m_line';
        })
</script>
Answer posted by Support on Jan 09, 2009 09:40
The code which you are using will add row after selected one, if you need to add row to the last position, you can use 
mygrid.addRow((new Date()).valueOf(),['','','','',false],-1)