Storing column values as a json string in the DB table and then sending them to the front end as a json object.
[
{
"jobId":"efe0ace0-8ed9-45ff-9232-974cbdc89b86",
"jobType":"TestExecutionJob",
"nextRun":"N/A",
"lastRun":"2015-11-26 13:26:10.664",
"createdDate":"2015-11-26 13:26:10.664",
"executor":"sam",
"JobDetails":"{\"environment\":\"AA\",\"EmailRecipients\":[\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed9e8c80c39e8c80dcdcad8a808c8481c38e8280">[email protected]</a>\"],\"extraParams\":{\"FileName\":\"myTest.xml\"}}",
"status":"active",
"elapsedTime":"18 minutes ago"
}
]
Incorporated angularJs ng-repeat
but nothing is displaying. Need help on accessing JobDetails
values (environment, EmailRecipients, and FileName).
<ul><li ng-repeat="t in row.entity.JobDetails">{{t.environment}}</li></ul>
JavaScript File
'use strict';
var tepTableModule = angular.module('test',
[ 'ngAnimate', 'ngTouch','ui.grid','ngResource' ]).factory('Service',
function($resource) {
return $resource('/api/jobs', {});
});
tepTableModule
.controller(
'tepTableCtrl',
function($scope, Service) {
$scope.TestData = Service.query();
var Plantemplate ='<div><ul><li ng-repeat="t in row.entity.JobDetails">{{t.FileName}}</li></ul></div>';
$scope.tableData = {
data : 'TestData',
groupsCollapsedByDefault : true,
enablePinning : true,
columnDefs : [ {
field : 'jobId',
displayName : 'jobId',
visible : false
}, {
field : 'JobDetails',
displayName : 'Plan Name',
cellTemplate : Plantemplate,
visible : true
},
{
field : 'jobType',
displayName : 'JobType',
visible : true
},
{
field : 'environment',
displayName : 'Environments',
visible : true
},
{
field : 'status',
displayName : 'Status',
visible : true
},
{
field : 'elapsedTime',
displayName : 'LastRun',
visible : true
},
{
field : 'JobDetails.EmailRecipients',
displayName : 'Email Recipients',
visible : true
},
{
field : 'executor',
displayName : 'Executor',
visible : true
}
],
sortInfo: {
fields: ['elapsedTime'],
directions: ['desc']
},
plugins : [ new ngGridAutoRowHeightPlugin() ]
};
$scope.changeGroupBy = function(group) {
$scope.gridOptions.groupBy(group);
}
$scope.clearGroupBy = function() {
$scope.gridOptions.$gridScope.configGroups = [];
$scope.gridOptions.groupBy();
}
});
HTML
<div ng-controller="tepTableCtrl">
<div ui-grid="tableData" class="grid"></div>
</div>