-2
$scope.departmentGrid = {
  data: 'deplist',
  enableRowSelection: true,
  multiSelect: false,
  modifierKeysToMultiSelect: false,
  enableRowHeaderSelection: false,
  noUnselect: true,
  enableColumnMenus: false,
  enableHorizontalScrollbar: 0,
  columnDefs: [{
      field: 'depId',
      enableCellEdit: true,
      displayName: 'Department Id',
      width: 180
    },
    {
      field: 'depName',
      enableCellEdit: true,
      displayName: 'Department Name'
    }
  ]
};
Nick Parsons
  • 45,728
  • 6
  • 46
  • 64
Wai Gyi
  • 1
  • 1

2 Answers2

0

You can handle this like below code: you have to use editable columnDefs property. editable will return a true or false according to the condition. and you can manipulate the condition according to the need of the requirement. if condition will return false then it will disable the editing and vice versa.

columnDefs: [{
      field: 'depId',
      editable: (params)=>{return params.data["depId"] === '' }
      displayName: 'Department Id',
      width: 180
    },
    {
      field: 'depName',
      editable: (params)=>{return params.data["depName"] === '' }
      displayName: 'Department Name'
    }
  ]
Dheeraj Kumar
  • 146
  • 1
  • 10
  • @WaiGyi can you please create one stackblitz of your requirement. it would be helpful to make changes directly over there to help you quickly. – Dheeraj Kumar Jun 29 '19 at 15:44
  • @WaiGyi please see : https://stackoverflow.com/questions/50341639/angular-grid-ag-grid-make-column-editable-dynamically . it might be helpful for you. – Dheeraj Kumar Jun 29 '19 at 15:48
0
  var cellEditable = function ($scope) {
        if ($scope.row.entity.depId === undefined)
            return true;
        else
            return false;
    };
    $scope.departmentGrid = {
        data: 'deplist',
        enableRowSelection: true,
        multiSelect: false,
        modifierKeysToMultiSelect: false,
        enableRowHeaderSelection: false,
        noUnselect: true,
        enableColumnMenus: false,
        enableHorizontalScrollbar: 0,
        columnDefs: [
            {field: 'depId', enableCellEdit: true, displayName: 'Department Id', width: 250, cellEditableCondition: cellEditable},
            {field: 'depName', enableCellEdit: true, displayName: 'Department Name'
            }
        ]
    };
Wai Gyi
  • 1
  • 1