2

If field key i have Boolean value always. What I want is if the value is true show the cell template otherwise hide it.

columnDefs: [{
            displayName: 'Advanced',
            field: 'advanced',
            enableSorting: true,
            enableFiltering: true,
            enableColumnResizing: false,
            cellTemplate: 'scripts/components/profiles/tm/programs/datagrid/advancedCellTemplate.html',
            maxWidth: 108,
            filter: {
                type: uiGridConstants.filter.SELECT,
                selectOptions: controller.programsPackage
            }
        }]

2 Answers 2

1

You can use angular.extend or Object.assign like this

const fields = [angular.extend({}, {
   displayName: 'Advanced',
   field: 'advanced',
   enableSorting: true,
   enableFiltering: true,
   enableColumnResizing: false,
   maxWidth: 108,
   filter: {
      type: uiGridConstants.filter.SELECT,
     selectOptions: controller.programsPackage
   }
 }, field ? {
     cellTemplate:  'scripts/components/profiles/tm/programs/datagrid/advancedCellTemplate.html'
} : null)]
Sign up to request clarification or add additional context in comments.

1 Comment

your solution and my solution both are working perfectly. thanks, cheers.
0

I find out the solution very simple, i just need to add the condition to the cell template based on field advanced value

'<div ng-if="row.entity.advanced">'

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.