1

I am using angularjs ui grid, I have field called status in my code, where user can update the status to either Active or InActive by clicking on button.

After update I am able to refresh the data, but celltemplate: condition is not getting fired. I am using below method to refresh ui grid

$scope.gridOption.data=data;
$scope.gridOptionApi.core.refresh();

but this is only refreshing my data, its not checking the condition which I have added in celltemplete which is as below

 {field: 'profileId', displayName: 'Change Status',cellTemplate:'<div class="text-center">
<button ng-click="grid.appScope.changeProfileStatus(COL_FIELD, \'InActive\' )" ng-show={{row.entity.status==\'Active\'}} 
class="btn-custome-warn custom-btn-xs  btn-warning"><i class="fa fa-close"></i></button><button 
ng-click="grid.appScope.changeProfileStatus(COL_FIELD, \'Active\')" ng-show={{row.entity.status==\'InActive\'}} 
class="btn btn-xs btn--small custom-btn-xs button--primary"><i class="fa fa-check"></i></button></div>'}

so basically I am showing change status field where if the status is active then I am showing button for Inactive it and vice versa.

Anyone any suggestions please?

here is plunker i tried to create to show u demo, but status here I am now updating manually to show you else I have api call for updating it, if you see data is changing but status change buttons are not changing Demo

5
  • I got the same issue with ng-show and ng-hide, try ng-if as an alternative, it may help. Some issue happens with ui-grid refresh Commented Jun 2, 2017 at 9:29
  • i tried with ng-if its not displaying anything then, not even html buttons also, so only I am using ng-show Commented Jun 2, 2017 at 9:37
  • Does ng-show need quotes like ng-show="{{row.entity.status==\'Active\'}}"? Commented Jun 2, 2017 at 9:50
  • ng-show="{{row.entity.status==\'Active\'}}" and ng-show={{row.entity.status==\'Active\'}} , both ways I tried, data is getting refreshed but buttons are not changing, which should change based on condition Commented Jun 2, 2017 at 9:55
  • @Icycool here is plunker i tried to create to show u demo, but status I am now updating manually to show u else I have api call for updating it, if you see data is changing but status change buttons are not changing plnkr.co/edit/iS8BOWsWI4CUAlapcy8P?p=preview Commented Jun 2, 2017 at 10:35

1 Answer 1

0

Got plunker to work by changing ng-show={{row.entity.status==\'Active\'}}

to ng-show="row.entity.status==\'Active\'"

Reason being anything inside {{ }} is executed inside the template immediately so you can see generated html has ng-show="true" but not an expression like

ng-show="row.entity.status=='Active'"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.