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 alternativeeditdropdownoptionsarray
when contents of dropdown depend on entity backing row.
here link tutorial
Comments
Post a Comment