Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional Cell Template in ui grid angular js

I need to display the text in a cell as a link based on a status or as a plain text. If the status is 'Deleted' the name should be displayed as plain text or else as an hyperlink. Below are my grid options. I am always getting it as hyperlink. Someone please help me correct my cell template so that I am getting it correct.

$scope.gridOptions = {
    data: 'ProjectDetails',
    columnDefs: [
    { field: 'Id', displayName: 'ID', visible: false },
    { displayName: 'Name', width: 200, cellTemplate: '<div> {{row.entity.ProjectStatus}} != Deleted </div>' ? '<div><a href="http://################ID={{row.entity.Id}}">{{row.entity.Name}}</a></div>' : '<div> {{row.entity.Status}}</div>' },
    { field: 'Expense', displayName: 'Operating Expense', width: 185, cellFilter: 'noFractionCurrency' },        
    { field: 'Status', displayName: 'Status', width: 150 }
    ]
};
like image 514
Janet Avatar asked Sep 17 '26 13:09

Janet


1 Answers

ng-if helped me.

cellTemplate: "<a target='_blank' ng-if=\"row.entity.Status != 'Deleted'\" 
href='#########?ID={{row.entity.Id}}'>{{row.entity.Name}}</a><div ng-
if=\"row.entity.Status == 'Deleted'\">{{row.entity.Name}}</div>" 
like image 66
Janet Avatar answered Sep 19 '26 06:09

Janet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!