0

I am using ui-grid. The use-case is such that on clicking a button, a new row is added. I want to make this newly added row editable. i.e. as soon as the row is added, the edit mode is on for at-least the first cell in the row. Any suggestions on how to do it ? Tried so far:

var newobj = {"id": "","name":"" }; 
$scope.gridOptions1.data.unshift(newobj);  
$scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ROW); //set focus to the new row 
$scope.gridApi.selection.selectRow($scope.gridOptions1.data[0]); 

here's a plunker for the same http://plnkr.co/edit/6zyZ5q?p=preview

arnavakhoury
  • 125
  • 1
  • 8
  • I am adding the new row by pushing a new object in the data array. this object has empty values. – arnavakhoury Apr 01 '16 at 04:13
  • what you have tried so for? – Suresh Kamrushi Apr 01 '16 at 04:46
  • var newobj = {"id": "","name":"" }; $scope.gridOptions1.data.unshift(newobj); $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ROW); //set focus to the new row $scope.gridApi.selection.selectRow($scope.gridOptions1.data[0]); – arnavakhoury Apr 01 '16 at 05:02
  • I added the new row to the array, the made enable edit on focus to true, and the tried to change the focus to the newly added row by using selectRow. Instead of selectRow i also tried focusing on the cell using cell nav, but nothing seems to work – arnavakhoury Apr 01 '16 at 05:03
  • here's a plunker http://plnkr.co/edit/6zyZ5q?p=preview It adds a new row, but i dont know how to make it editable as soon as it is added. – arnavakhoury Apr 01 '16 at 10:09
  • in the plunker you provided, the new row is editable as soon as it's added. all you have to do is click a cell and start typing (or double-click). – Bennett Adams Apr 02 '16 at 13:30
  • I want it to directly go in the edit mode, i.e. , without the user clicking it. Automatically, the first cell should be in edit mode – arnavakhoury Apr 04 '16 at 04:36
  • It works now. Just set the editable flag of the cell to true. – arnavakhoury Oct 10 '17 at 09:03

0 Answers0