suman goud

suman goud

  • NA
  • 176
  • 54.1k

How to get dropdown selected id data in table grid in Angula

Sep 23 2016 6:20 AM
<table >
<tr>
<th>Customer</th>
<th>Pendings</th>
<th>Pending Value</th>
</tr>
<tr ng-repeat="r in rvm">
<td>
<select ng-model="c" ng-change="GetAccountBalance($index,c)" ng-options="c.ID as c.Name for c in customer track by c.ID" style="width:150px;height:22px;" name="tCustomer">
<option value="">select Customer</option>
</select>
</td>
<td>
<input type="text" ng-model="ReceiptsViewModel.PendingAmount" class="input-large" name="tPendingValue" readonly />
</td>
<td>
<input type="text" ng-model="ReceiptsViewModel.AdjustAmount" class="input-large" name="tPendingAdjusted" readonly />
</td>
</tr>
</table>
JS
$scope.rvm = [{}];
$scope.GetAccountBalance = function (index, c) {
//adding new row on dropdown change
if ($scope.rvm.length == (index + 1)) {
$scope.rvm.push({
});
}
var getPendingData = ReceiptsService.GetPendings(c);
getPendingData.then(function (d) {
//var x;
//for (x in d.data)
//{
// alert('in');
// $scope.ReceiptsViewModel = d.data;
//}
alert($scope.rvm.length);
$scope.ReceiptsViewModel = d.data;
$scope.ReceiptsViewModel.PendingAmount = $scope.ReceiptsViewModel.Amount - $scope.ReceiptsViewModel.AmountAdjusted;
}, function (error) {
alert('Error');
});
}
controller
public JsonResult GetPendings(int? pendingID)
{
string eid = pendingID.ToString();
TestDemoEntities db = new TestDemoEntities();
var data = (from ap in db.Accounting_PendingBills
join apa in db.Accounting_PendingBillsAdjusted on ap.BillRef equals apa.TowardsBillRef
group apa by new { ap.BillDate, ap.Amount, ap.Party, apa.TowardsBillRef } into g
select new
{
BillDate = g.Key.BillDate,
Party = g.Key.Party,
Amount = g.Key.Amount,
BillNumber = g.Key.TowardsBillRef,
AmountAdjusted = g.Sum(aa => aa.AmountAdjusted)
}).Where(ap => ap.Party == eid).FirstOrDefault();
return Json(data, JsonRequestBehavior.AllowGet);
}
by using follwing table am adding new row on dropdown change,and getting selected id data from database ,and binding that to table,
my problem is same data is binding to that added new row also(except dropdown:it is showing select customer ).again if i select another
customer from database getting data correctly,but the data is binding to all.
how to fix this issue, i have tried by giving loop

Answers (3)