Hi,
currently in that i am going to do check/uncheck relevant fields(Selected,Add,Edit)
My requirement in this form is
1) If i have select all need to check all respective fiels (Selected,Edit, and Add)
2) If i have checked particular Customer Id Row then check Edit and Add fields on that particular row
3) If i have uncheck any of field(Add,Edit) then uncheck Customer Id check box (Selected)
@{
Layout = null;
}
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', [])
app.controller('MyController', function ($scope) {
$scope.Customers = [
{ CustomerId: 1, Name: "John Hammond", Country: "United States", Selected: false,Add:false ,Edit:false},
{ CustomerId: 2, Name: "Mudassar Khan", Country: "India", Selected: false, Add: false,Edit:false },
{ CustomerId: 3, Name: "Suzanne Mathews", Country: "France", Selected: false, Add: true, Edit: false },
{ CustomerId: 4, Name: "Robert Schidner", Country: "Russia", Selected: false, Add: true, Edit: false }
];
$scope.CheckUncheckHeader = function () {
$scope.IsAllChecked = false;
for (var i = 0; i < $scope.Customers.length; i++) {
if (!$scope.Customers[i].Selected) {
$scope.IsAllChecked = false;
break;
}
};
};
$scope.CheckUncheckHeader();
$scope.CheckUncheckAll = function () {
for (var i = 0; i < $scope.Customers.length; i++) {
$scope.Customers[i].Selected = $scope.IsAllChecked;
}
};
});
</script>
<div ng-app="MyApp" ng-controller="MyController">
<table cellpadding="0" cellspacing="0">
<tr>
<th align="left">
<label>
<input type="checkbox" ng-model="IsAllChecked" ng-change="CheckUncheckAll()" />
CustomerId
</label>
</th>
<th>Name</th>
<th>Country</th>
<th>Add</th>
<th>Edit</th>
</tr>
<tbody ng-repeat="m in Customers">
<tr>
<td>
<label for="chkCustomer_{{m.CustomerId}}">
<input id="chkCustomer_{{m.CustomerId}}" type="checkbox" ng-model="m.Selected" ng-change="CheckUncheckHeader()" />
{{m.CustomerId}}
</label>
</td>
<td>{{m.Name}}</td>
<td>{{m.Country}}</td>
<td><input type="checkbox" ng-model="m.Add" /></td>
<td><input type="checkbox" ng-model="m.Edit" /></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Could you please help me