admin管理员组

文章数量:1278858

I have an ag-grid that I need to be able to edit via the keyboard. I have the editType set to fullRow and I'd like to be able to add javascript so that when I fire the onRowEditingStarted event, it goes to the first editable cell because occasionally, my grid is larger than the screen.

I can get the rowIndex, but I cannot get a hold of the collection of columns to look at the properties. I want to keep the rowIndex, but get the first editable column and set focus there. (Right now, it's whatever is incidentally selected to fire the event.)

Does anyone have an example that I can look at?

I've tried looking through the objects produced here:

onRowEditingStarted: function(params) {
   console.log("started row editing");
   console.log(params);
}

This gives me an event where I can get the rowIndex and the columnApi. I would expect somewhere in here is a collection to do a for loop, but I don't see it.

I have an ag-grid that I need to be able to edit via the keyboard. I have the editType set to fullRow and I'd like to be able to add javascript so that when I fire the onRowEditingStarted event, it goes to the first editable cell because occasionally, my grid is larger than the screen.

I can get the rowIndex, but I cannot get a hold of the collection of columns to look at the properties. I want to keep the rowIndex, but get the first editable column and set focus there. (Right now, it's whatever is incidentally selected to fire the event.)

Does anyone have an example that I can look at?

I've tried looking through the objects produced here:

onRowEditingStarted: function(params) {
   console.log("started row editing");
   console.log(params);
}

This gives me an event where I can get the rowIndex and the columnApi. I would expect somewhere in here is a collection to do a for loop, but I don't see it.

Share Improve this question asked Feb 5, 2019 at 16:46 newbonewbo 971 gold badge2 silver badges8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You could do something like in your onRowEditingStarted

// scrolls to the first column, or first editable column. you can pass in the correct index
var firstEditCol = params.columnApi.getAllDisplayedColumns()[0];
/////
params.api.ensureColumnVisible(firstEditCol );

// sets focus into the first grid cell
params.api.setFocusedCell(params.rowIndex, firstEditCol);  

This example from docs is a good starting point

本文标签: javascriptHow do I set the focus on the first editable cell in a row onRowClickedStack Overflow