Mahesh Reddy

Mahesh Reddy

  • NA
  • 363
  • 16.9k

Id is displaying instead of Name on product

Dec 20 2018 1:20 AM
Hi,
I have 3 tables
Product
.............
ProductID  ProductName
1                Apple
2                 Lenovo
Orders
............
OrderId  OrderName
1             aaa
2             bbb
Items
...........
Id   Name   OrderId  ProductID
1   dd           1           2 
 2   frr           1           1
3     ruur       2            1
i have one form and grid view 
in grid view i jave one button 
after clicking of that button i have to display relevant values on form based upon OrderId
 In form relevant values are dispaying properly except at product
in Product it was dispalying only Id insted of Name 
Could please any body help me 
I am sharing here my edit script code
 Code
............................ 
$scope.Edit = function (OrderId) {
debugger;
$scope.invoice = true;
var id = OrderId;
//var id = $scope.employees[index].OrderId;
$.post("/invoice/Edit/", { orderID: id }, function (r) {
debugger;
$scope.OrderId = r.Orders.OrderId;
$scope.OrderName = r.Orders.OrderName;
$scope.myData = [];
for (var i = 0; i < r.Items.length; i++) {
var customer = {};
customer.OrderId = r.Items[i].Names;
customer.OrderName = r.Items[i].Name;
customer.Id = r.Items[i].Id;
customer.Product = r.Items[i].ProductID;
customer.Name = r.Items[i].Name;
$scope.myData.push(customer);
}
});
}
View
...................
<tbody style="padding-left:20px; padding-right:20px;" ng-model="myData1" ng-repeat="invoice in myData track by $index">
<tr>
<td>
{{invoice.id}}
</td>
<td>
{{invoice.Product}}
</td>
<td>
{{invoice.Name}}
</td>
</tr>
</tbody>
<tfoot>
<tr style="padding-left:20px; padding-right:20px;" ng-show="mahesh">
<td ng-model="Id">
{{$index+1}}
</td>
<td>
<select class="input-sm form-control" select2="" name="ProductName" ng-model="Product" containerCssClass="all" ng-options="s as s.ProductName for s in products" ng-disabled="disabled">
<option value="">-- Select Product --</option>
</select>
</td>
<td>
<input type="text" ng-model="Name" class="input-sm form-control" />
</td>
<td>
<button type="button" class="btn btn-success btn-sm" ng-click="add()"><span class="glyphicon glyphicon-plus"></span></button>
</td>
</tr>
</tfoot>
 
 
 
 

Answers (5)