0

I want to add a Cancel button that will update the status from open to cancelled for all the selected checkboxes.

The cancel button should change the status to Cancelled.

Below is the code for the cancel button.

                    <div>
                        <button type="button" class="btn btn-danger btn-lg text-left" id="btnCancelSelectedOrderLines" name="btnCancelSelectedOrderLines" ng-click="dsoedit.OnCancelSelectedOrderLines()">Cancel Lines</button>
                    </div>

The checkboxes are displayed using ng-repeat.

                            <tr ng-repeat="o in dsoedit.OrdLines">
                                <td>
                                    <md-checkbox aria-label="Select Order Line" ng-model="o.IsSelected" ng-change="selectEntity()"></md-checkbox>
                                </td>
                                <td>
                                    <H5 class="btn-h-spacer">{{o.LineNbr}}</H5>
                                </td>
                                <td>
                                    <H5 class="btn-h-spacer">{{o.Status}}</H5>
                                </td>
…

My goal here is to cancel the orders where the checkboxes are selected. I'm trying to send the selected values to the ng-click function OnCancelSelectedOrderLines as an array parameter. Is there a way to send the o.LineNbr values as an array for the selected checkboxes to the OnCancelSelectedOrderLines as a parameter? (something like this OnCancelSelectedOrderLines(o.LineNbr))

Anup Deuja
  • 43
  • 7
  • Does this answer your question? [How do I bind to list of checkbox values with AngularJS?](https://stackoverflow.com/questions/14514461/how-do-i-bind-to-list-of-checkbox-values-with-angularjs) – derloopkat Jan 19 '21 at 20:09
  • @DanielManta I was able to achieve my solution by passing in the entire ng-model dsoedit.OrdLines as an parameter. Updated by ng-click Cancel button to ng-click="dsoedit.OnCancelSelectedOrderLines(dsoedit.OrdLines)" And in my javascript function, I used filter to select the selected checkboxes. var selectedOrderLines = OrdLines.filter(ordLine => ordLine.IsSelected === true); – Anup Deuja Jan 20 '21 at 14:32

1 Answers1

0

I was able to achieve my solution by passing in the entire ng-model dsoedit.OrdLines as an parameter.

Updated by ng-click Cancel button to

ng-click="dsoedit.OnCancelSelectedOrderLines(dsoedit.OrdLines)"

And in my javascript function, I used filter to select the selected checkboxes.

var selectedOrderLines = OrdLines.filter(ordLine => ordLine.IsSelected === true);

Anup Deuja
  • 43
  • 7