0

My code is below from an Angular js file,

ctrl.issuesGridConfig = {
        modelSetName: 'issues',
        serializerChildName: 'issues', //will be prepended with "__" before fields for validation
        actions: {
            addRow: {
                active: function(row) {return !ctrl.readOnly;},
                callback: addIssueRow,
            },
            editRow: {
                active: function(issue){ return issue.provider_issue_code;} ? true : false,
                label:  "View test" : "Edit",
                callback: function(issue){
                    $location.path('/issue/' + issue.provider_issue_code);
                }
            },
            deleteRow: {
                active: function(row) {return !ctrl.readOnly;},
                callback: function(row){
                    _.pull(ctrl.activity.issues, row);
                }
            }
        },

My problem is- under the Editrow I am running the function(issue). it is working fine in callback:, but for active: it does not work. I get value of issue.provider_issue_code under callback:, but not under active:. I want to make active = true only if issue.provider_issue_code has some value. Please let me know whats going wrong here.

1
  • function(issue){ return issue.provider_issue_code;} ? true : false This line doesn't make any sense to me. You're defining a function, then testing if it exists, and if it exists, return true else return false. But it does exist since you're precisely defining it, so active will always be true... Commented Jul 4, 2017 at 11:48

1 Answer 1

1

Wrong code there, active is always true because of your wrong typo, in your code you assign active with a ternary operator: active = condition ? true : false; (the function is the condition there)

active: function(issue){ return issue.provider_issue_code;} ? true : false,

should be

active: function(issue){ return issue.provider_issue_code ? true : false;} ,

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

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

1 Comment

Thanks,Yes it was typo. and I didnt got any error while running so was confused what was wrong.

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.