2 questions about editable grid

Hello,

Here is a grid, the purpose is to create proposal and invoice.

  1. When I click on the button “Ajouter” (Add), I would like the cursor is directly in the first cell of the next row and the cell is in edit mode.
    I try this :
    devisGrid = devisLayout.cells(“c”).attachGrid();
    devisGrid.setHeader(“Référence,Désignation,Qté,Unité,Px Unitaire,Px Total”);
    devisGrid.setColumnIds(“reference,designation,quantite,unite,prix_unit,prix_total”);
    devisGrid.setInitWidths(“80,389,60,64,82,82”);
    devisGrid.setColAlign(“left,left,right,right,right,right”);
    devisGrid.setColTypes(“ed,txttxt,edn,ed,edn,ron[=c2*c4]”);
    devisGrid.setNumberFormat(“000.00 €”,4);
    devisGrid.setNumberFormat(“0,000.00 €”,5,“.”,“,”);
    devisGrid.enableAutoWidth();
    devisGrid.attachFooter(“Total,#cspan,#cspan,#cspan,#cspan,#stat_total”);
    devisGrid.enableEditEvents(true,false,true);
    devisGrid.init();

    devisGrid.callEvent(“onGridReconstructed”,[]);

    devisToolBar.attachEvent(“onclick”,function(id){
    if(id==“add”)
    {
    var rowId = devisGrid.uid(); // ----- generates an unique id
    devisGrid.addRow(rowId, [“”,“Nouvelle ligne”,“”,1,“”], devisGrid.getRowsNum());
    //devisGrid.selectRowById(rowId);
    devisGrid.selectCell(rowId, 0, true, true, true);
    devisGrid.editCell();
    devisGrid.selectRowById(rowId);
    };
    });

  2. I need to add a new row to have the total, in the footer, calculated. How can I make this automatic ?

Thanks for your help

Best regards

(1)

You need to change your code like next

devisGrid.addRow(rowId, ["",“Nouvelle ligne”,"",1,""], devisGrid.getRowsNum());
setTimeout(function(){
    devisGrid.selectCell(devisGrid.getRowIndex(rowId), 0, false, true, true);
},1);

Normally any click outside of the grid closes the editor, so the setTimeout is necessary to run the selection/edit code when click processing is fully finished.

(2)
You can have stat counter in the footer. Check
https://docs.dhtmlx.com/grid__statistics_counter.html

mygrid.attachFooter("#stat_total,,");