DHTMLX Docs & Samples Explorer

Edit actions

There is an opportunity to define edit operations:

Edit on click
Edit on double click
Edit on F2 key
Selected row:

Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script  src="../../codebase/dhtmlxcommon.js"></script>
<script  src="../../codebase/dhtmlxgrid.js"></script>        
<script  src="../../codebase/dhtmlxgridcell.js"></script>
 
 
 
<table width="600">
    <tr>
        <td width="50%" valign="top">
            <div id="gridbox" style="width:100%;height:270px;background-color:white;"></div>
        </td>
    </tr>
    <tr>
        <td>
            <div><input id='z1' type="checkbox"  onclick='doEditEvents()'>Edit on click</div>
            <div><input id='z2' type="checkbox" checked='true' onclick='doEditEvents()'>Edit on double click</div>
            <div><input id='z3' type="checkbox" checked='true' onclick='doEditEvents()'>Edit on F2 key</div>
            <div id='logBox'>Selected row:</div>
        </td>
    </tr>
</table>
<br>
 
<script>
function doOnRowSelect(id) {
    document.getElementById("logBox").innerHTML = "Selected row: " + id;
}
function doEditEvents() {
    mygrid.enableEditEvents(document.getElementById('z1').checked, document.getElementById('z2').checked, document.getElementById('z3').checked);
}
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
mygrid.setInitWidths("50,150,120,80,80,80,80,200");
mygrid.setColAlign("right,left,left,right,center,left,center,center");
mygrid.setColTypes("dyn,ed,ed,price,ch,co,ra,ro");
mygrid.enableEditEvents(false, true, true);
mygrid.attachEvent("onRowSelect", doOnRowSelect);
mygrid.getCombo(5).put(2, 2);
mygrid.setColSorting("int,str,str,int,str,str,str,date");
mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("../common/grid.xml");
</script>