Hi,
Display relevant files after clicking of Id in grid view at relevant rows
I have 2 tables on database
Employee
Id Name
1 aaa
2 bbbb
Documents
DId DocName Id
1 ~/uploadfiels/mahesh.text 1
2 ~/uploadfiels/mahesh.text 1
3 ~/uploadfiels/mahesh2.text 1
4 ~/uploadfiels/resume.text 2
5 ~/uploadfiels/word.text 2
6 ~/uploadfiels/file.2text 2
i have one grid view after clicking of edit button in grid view
i need to display relevant files on partular row
could you please help me
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Index</title>
<script type="text/javascript" src="https://code.angularjs.org/1.4.3/angular.js"></script>
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller('MainCtrl', function ($scope, $http) {
$scope.employees = [{ Name: 'aa' }, { Name: 'bb'}];
$scope.files = [];
});
app.directive('ngFileModel', ['$parse', function ($parse) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var model = $parse(attrs.ngFileModel);
var isMultiple = attrs.multiple;
var modelSetter = model.assign;
element.bind('change', function () {
var values = [];
angular.forEach(element[0].files, function (item) {
var value = {
// File Name
name: item.name,
//File Size
size: item.size,
//File URL to view
url: URL.createObjectURL(item),
// File Input Value
_file: item
};
values.push(value);
});
scope.$apply(function () {
var index = scope.$index;
if (isMultiple) {
modelSetter(scope, values);
scope.$parent.employees[index].files = values;
} else {
modelSetter(scope, values[0]);
scope.$parent.employees[index].files = values[0];
}
});
});
}
};
} ]);
</script>
</head>
<body ng-app="myApp" ng-controller="MainCtrl">
<input type="text" ng-model="EName" />
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Name</th>
<th>UploadFile</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee in employees">
<td><input type="text" ng-model="employee.Name" /></td>
<td><input type="file" ng-file-model="files" multiple /></td>
</tr>
</tbody>
</table>
</body>
</html>
<table class="table table-bordered table-hover table-striped">
<tr>
<th>Id</th>
<th>Name</th>
<th>DocName</th>
</tr>
<tbody ng-repeat="e in employees">
<tr>
<td>{{e.Id}}</td>
<td>{{e.Name }}</td>
<td>{{e.DocName }}</td>
<td></td>
</tr>
</tbody>
</table>