Start edit on selected cell in normal edit mode

Hi,

On the grid, how do I go about starting edit mode on the selected cell in normal edit mode?

I currently have the following in my load event:

function load(args) {

    var gridObj = document.getElementById('TheGridGrid1').ej2_instances[0];

    gridObj.element.addEventListener('mouseup', function (e) {

        if (e.target.classList.contains("e-rowcell")) {

            if (gridObj.isEdit) {

                gridObj.endEdit();

            }

            var index = parseInt(e.target.getAttribute("Index"));

            gridObj.selectRow(index);

            var cellIndex = parseInt(e.target.getAttribute('aria-colindex'));

            gridObj.selectCell(cellIndex);

            gridObj.startEdit();

        }

    });

}


But when I click on the cell I want to edit, It always jumps back to the first editable cell and not the selected cell (the one I click on).


3 Replies 1 reply marked as answer

PS Pavithra Subramaniyam Syncfusion Team December 2, 2021 12:30 PM UTC

Hi Eddie, 

Thanks for contacting Syncfusion support. 

You can achieve your requirement by focusing the selected cell inside the “actionComplete” event. Please refer to the below code example for more information. 

var cellIndex; 
function load(args) { 
  var gridObj = document.getElementById('Grid').ej2_instances[0]; 
 
  gridObj.element.addEventListener('mouseup'function (e) { 
    if (e.target.classList.contains('e-rowcell')) { 
      .   .   . 
      cellIndex = parseInt(e.target.getAttribute('aria-colindex')); 
      .   .   . 
    } 
  }); 
} 
 
function actionComplete(args) { 
  if (args.requestType === 'beginEdit') { 
    //'Grid' is Grid element id 
    args.form.elements['Grid' + gridObj.getColumnByIndex(cellIndex).field].focus(); 
  } 
} 


Regards, 
Pavithra S 


Marked as answer

EW Eddie Willcox replied to Pavithra Subramaniyam December 3, 2021 06:46 AM UTC

Thank you. This is exactly what I was looking for



PS Pavithra Subramaniyam Syncfusion Team December 3, 2021 10:43 AM UTC

Hi Eddie, 

Thanks for your update. 

It is great to hear that the provided solution helped you! Please contact us if you have any other queries. As always, We are happy to assist you. 

Regards, 
Pavithra S 


Loader.
Up arrow icon