TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
suman goud
NA
176
54.1k
How to fix, binding duplicate data on adding table row
Oct 4 2016 5:41 AM
i have table grid with one customer dropdown, and button(on click showing modal popup for pending values) two input values and + buton to add new row
am able to get pending data correctly on change, but
am substracting two values here, Amount and AmountAdjusted then binding that value in PendingAmount(span) .
am getting value, but when i adding row same value repeating
<table>
<tr>
<th>Customer</th>
<th>Pendings</th>
<th>Pending Adjusted</th>
</tr>
<tr ng-repeat="r in rvm">
<td>
<select ng-model="c" ng-change="GetAccountBalance(c)" ng-options="c.ID as c.Name for c in customer track by c.ID" style="width:150px;height:22px;" name="tCustomer" required>
<option value="">select Customer</option>
</select>
</td>
<td>
<button type="button" data-toggle="modal" ng-click="GetAccountBalance(c)" data-target="#ShowPendings">Pendings</button>
<!-- Modal -->
<div class="modal fade" id="ShowPendings" role="dialog">
<div id="modelPendings" class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Pendings</h4>
</div>
<div class="modal-body">
<table>
<tr>
<th> Bill Amount </th>
<th>Already Adjusted </th>
</tr>
<tr ng-repeat="rm in ReceiptsViewModel">
<td>
{{rm.Amount}}
</td>
<td>
{{rm.AmountAdjusted}}
</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" style="background-color:#b5fab2">Submit</button>
<button type="button" class="btn btn-default" data-dismiss="modal" style="background-color:#b5fab2">Close</button>
</div>
</div>
</div>
</div>
</td>
<td>
<span id="spAmount">{{PendingAmount}}</span>
</td>
<td>
<input type="text" ng-value="0.00" ng-model="PendingAdjusted" class="input-large" name="tPendingAdjusted" readonly />
</td>
<td ng-if="$last">
<a href="#">
<span class="glyphicon glyphicon-plus orange" ng-click="addRow($index,c)"></span>
</a>
</td>
<td ng-if="!$last">
<a href="#">
<span class="glyphicon glyphicon-minus orange" @*data-toggle="modal" data-target="#delteConfirmation"*@ ng-click="deleteRow($index)"></span>
</a>
</td>
</tr>
</table>
JS
$scope.rvm = [{}];
$scope.ReceiptsViewModel = [];
$scope.GetAccountBalance = function (c) {
$scope.fetch = true;
var getPendingData = ReceiptsService.GetPendings(c);
getPendingData.then(function (d) {
$scope.ReceiptsViewModel = d.data;
//subtracting here
$scope.PendingAmount = $scope.ReceiptsViewModel[0].Amount - $scope.ReceiptsViewModel[0].AmountAdjusted;
$scope.fetch = false;
});
}
Reply
Answers (
2
)
Insight of Reflection
How to store multiple checkbox value