javascript - Why the gridApi.on.edit.beginCellEdit in angular-ui-grid cannot update the new drop-down options immeidiately? -


i have same problem 1 why ui grid value drop-down box assigned in event fires before begincelledit in angular , have little bit difference. after updated editdropdownoptionarray still keep old value, it's have new value in next click.

hope can me one. thank you.

here code snippet:

the html of dropdown:

<div>     <form name="inputform">         <select ng-class="'colt' + col.uid"                 ui-grid-edit-dropdown                 ng-model="model_col_field"                 ng-options="field custom_filters field in editdropdownoptionsarray"></select>     </form> </div> 

the controller code:

$scope.menucolumns = [                         { displayname: 'menu', field: 'name', enablecelledit: false },                         {                             displayname: 'access level', field: 'accesslevelname',                             editablecelltemplate: 'scripts/application/role/directive/dropdown-menu-assignment.html',                             editdropdownvaluelabel: 'access level', editdropdownoptionsarray: usermgtconstant.menuaccesslevel                         }                     ];                      $scope.menuoptions = {                         data: [],                         onregisterapi: function (gridapi) {                             gridapi.edit.on.begincelledit($scope, function (rowentity, coldef, event) {                                 if (rowentity.parent === true) {                                     coldef.editdropdownoptionsarray = $scope.levellist;                                 } else {                                     coldef.editdropdownoptionsarray = $scope.childlevellist;                                 }                             });                             gridapi.edit.on.aftercelledit($scope, function (rowentity, coldef, newvalue, oldvalue) {                                 if (rowentity.parent !== true) {                                     if(rowentity.name === 'revenue bench'){                                         var accesslevel = commonutils.getidfromname(rowentity.accesslevelname, usermgtconstant.menuaccesslevel);                                         if(accesslevel > 1){                                             $scope.isshowfunctionassignment = false;                                         } else if(rowentity.functionassignments.length !== 0) {                                             $scope.isshowfunctionassignment = true;                                         }                                     }                                 } else {                                     // udpate child dropdown list menu                                     var index = _(usermgtconstant.menuaccesslevel).indexof(newvalue);                                     $scope.childlevellist = $scope.levellist.filter(function (item, i) {                                         return >= index;                                     });                                      if($scope.childlevellist.length > 2){                                         parentswitch = true;                                     }                                      if($scope.childlevellist.length < 3 && parentswitch){                                         coldef.editdropdownoptionsarray = $scope.childlevellist;                                         parentswitch = false;                                     }                                      // update child value                                     _($scope.menuoptions.data).each(function (dataitem) {                                         if (dataitem.parent !== true) { // prevent infinite loop                                             dataitem.accesslevelname = newvalue;                                         }                                     });                                 }                             });                         }                     }; 

here usage of grid:

<inline-edit-grid options="menuoptions" columns="menucolumns"></inline-edit-grid> 

you should usage of editdropdownrowentityoptionsarraypath instead of editdropdownoptionsarray

from docs :

editdropdownrowentityoptionsarraypath can used alternative editdropdownoptionsarray when contents of dropdown depend on entity backing row.

here link tutorial


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -