How can i solve unknown provider issue in AngularJS with Kendo? - angularjs

I want to populate data into kendo grid but I am getting an error unknown provider:Error: [$injector:unpr] Unknown provider: promiseObjProvider <- promiseObj <- ProcessController <- ProcessController. I am not sure where i am making mistake.Please see below code and advise how can i reslove this problem.
createEditProcess.html
<div class="panel panel-primary">
<div class="panel-heading">
<label ng-hide="editMode">Create New Process </label>
<label ng-show="editMode">Edit Process </label>
</div>
<div class="tabContent">
<form name="createProcessFormName" id="createProcessForm"
name="form" role="form" class="form-horizontal"
kendo-validator="validator" k-validate-on-blur="false" k-options="myValidatorOptions" ng-submit="validate($event)">
<div kendo-window="ERHPopup" k-title=""
k-width="350" k-height="100" k-visible="false" >
<div><span>This Process Has Risks And Controls Aligned To It. Please Review And Adjust Those If Necessary</span></div>
</div>
<div kendo-window="geographicLocationsPopup" k-title=""
k-width="350" k-height="100" k-visible="false" >
<div><span>This Process Has Risks And Controls Aligned To It. Please Review the Risks and Controls</span></div>
</div>
<div kendo-window="legalEntitiesPopup" k-title=""
k-width="350" k-height="100" k-visible="false" >
<div><span>This Process Has Risks And Controls Aligned To It. Please Review the Risks and Controls</span></div>
</div>
<div kendo-window="EPCFPopup" k-title=""
k-width="350" k-height="100" k-visible="false" >
<div><span>This Process Has Risks And Controls Aligned To It. Please Review The Risks And Controls</span></div>
</div>
<ng-include src="'views/createEditProcessContent.html'"></ng-include>
</form>
</div>
</div>
<div kendo-window="confirmationWin" options="confirmationWinOptions" class="confirmationWin"></div>
</script>
processController.JS
angular.module('riskAssessmentApp').controller('ProcessController', function($scope, Process,TreeViewData, $rootScope,
$routeParams, ViewEditPrcsService, kendoCustomDataSource, $http,EPCFHirachyInfo,ERhHirachyInfo,
$location,alert,ProcessUpdate, ihtRskRatingGridConfig, processTreeConfig, alignedRisksHeaderPallette, alignedRisksModal,
riskToControlGridDataService,controlToProcessConfig,savaControlToProcessGrid, riskRatingGrid,savaControlToProcessNoAlignGrid, processRatingGridConfig, Rating, alignExstRskDataService, alignedCtrlsHeaderPallette, alignExstRiskGrid,ConfirmationConfig,promiseObj) {
'use strict';
var resetDataPrt = function() {
return new kendo.data.DataSource({
data: $scope.processRating,
navigatable: true,
pageSize: 100
});
};
if($scope.editMode){
$scope.ihtRskRatingGridOptions = ihtRskRatingGridConfig.ihtRskRatingGrid;
ihtRskRatingGridConfig.ihtRskRatingGrid.dataSource = resetData2();
$scope.processRating = promiseObj.data;
$scope.processRatingGridOptions = processRatingGridConfig.processRatingGrid;
processRatingGridConfig.processRatingGrid.dataSource = resetDataPrt();
});
APP.JS
.when('/process/create', {
templateUrl : 'views/createEditProcess.html',
controller : 'ProcessController',
resolve: {
promiseObj: function(Rating){
return Rating.getAllProcessRatings();
}
}
})
processGrid.js
angular.module('riskAssessmentApp').value('processRatingGridConfig', {
processRatingGrid: {
columns: [{
field: 'ratingDateHistory',
title: 'History',
width: '8em'
}, {
field: 'irrComputed',
title: 'Process Inherent Risk Rating Computed',
width: '10em'
}, {
field: 'irrFinalOutcome',
title: 'Process Inherent risk business Final',
width: '10em'
}, {
field: 'mssControlFlag',
title: 'Missing controls',
width: '10em'
}, {
field: 'computedEffectiveRating',
title: 'Overall Control Effectiveness Computed',
width: '10em'
}, {
field: 'businessEffectiveRating',
title: 'Overall Control Effectiveness Business',
width: '10em'
}, {
field: 'effectiveJustification',
title: 'Control Effectiveness Business Justification',
width: '10em'
}, {
field: 'residualRiskComputed',
title: 'Residual Risk Computed',
width: '10em'
}, {
field: 'businessResidualRisk',
title: 'Residual Risk Business',
width: '10em'
}, {
field: 'residualRiskJustification',
title: 'Residual Risk Business Justification',
width: '10em'
}, {
field: 'riskDescription',
title: 'Risk Description',
width: '10em'
}, {
field: 'riskAcceptanceFlag',
title: 'Risk Acceptance',
width: '10em'
}, {
field: 'riskAcceptanceRationale',
title: 'Risk Acceptance Rationale',
width: '10em'
}]
},
});
Factory.js
angular.module("riskAssessmentApp").factory('Rating', function($http, $location) {
getAllUpdateQuestions: function (prcsSessionKey) {
return $http.get('app/processrating/rest/getProcessRating/' +prcsSessionKey);
},
getAllProcessRatings: function (processKey) {
return $http.get('app/processrating/rest/getProcessRatings/' + processKey);
}
};
});

In the line: <div class="panel panel-primary" ng-controller> remove ng-controller

Related

Column Title not showing as designed

ShieldUI v 1.7.36 NP
URL: http://hccm.org/gala_signup_list.php
Code
HTML:
<div class="about-bottom">
<div class="col-md-12 about-left">
<div id="grid"></div>
</div>
</div>
Javascript:
$(document).ready(function() {
$('#return_btn').click(function() {
window.location = 'gala.php';
})
plgrid = $("#grid").shieldGrid({
dataSource: {
remote: {
read: {
url: "api/GetGalaSignupList",
dataType: "json",
xhrFields: {
withCredentials: false
}
}
},
noRecordsText: "There are no Registrants",
columns: [
{field:'registrant_name', title: "Registrant Name", width: "30%"},
{field: 'registrant_email', title: "Email", width: "30%"},
{field: 'registrant_phone', title: "Phone"},
{field: 'registrant_mail', title: "Address", width: "30%"},
{field: 'table_name', title: "Table Name", width: "20%"},
{field: 'numtix', title: "Num Tix", width: "20%"}
]
}
});
plgrid.show();
});
Data, <snip> data can be seen at URL
[
{
"registrant_name":"Jeff Seiler",
"registrant_email":"<snip>",
"registrant_phone":"<snip>",
"registrant_mail":"507 Las Colinas",
"ticket_type":"Individual",
"table_name":"Mr and Mrs Jeff Seiler",
"numtix":"2"
},
{
"registrant_name":"Jan Halstead",
"registrant_email":"<snip>",
"registrant_phone":"<snip>",
"registrant_mail":"115 Mason Oaks",
"ticket_type":"Individual",
"table_name":"",
"numtix":"1"
}
]
But it isn't showing the title based on the title attributes, it shows only JSON column names. What am I doing wrong to cause this? I can change my JSON but am wondering why the title attribute isn't working.
I see you are reading data remotely from an url, I think you should define a
schema of the fields used in the datasource. You can check here how they are
defined. You should point the path and data type.
https://www.shieldui.com/documentation/datasource/javascript/api/settings/schema/fields
I suspect the cause of not showing the titles is that you have not defined field schema.

angular js: UI Grid set onclick event row and identify clicked row

$http({
method: 'GET',
url: "http://localhost:9080/ProdMakerDev/pm/managejobs/search/"+val
}).then(function successCallback(response) {
$scope.gridOptions.data = response.data;
}, function errorCallback(response) {
});
}
$scope.gridOptions = {
columnDefs: [
{ name:'Status', field: 'Status', width: "65", cellTemplate:"<div class={{row.entity.Status}}></div>"},
{ name:'', field:'edit/delete/startnow' , width: "70",
cellTemplate:" <img src='Images/edit.gif' /> <img src='Images/delete.gif' /> <img src='Images/startnow.gif' />" },
{ name:'Jobname', field: 'Jobname', width: "297"},
]
};
in above screenshot. on click of edit button edit the name & delete vice versa.
Please help me.
You can use this below code if you want to attach any event to row elements.
ng-click="grid.appScope.<>(row, $event)"
For e.g:
$scope.gridOptions = {
columnDefs: [
{ name:'Status', field: 'Status', width: "65", cellTemplate:"<div class={{row.entity.Status}}></div>"},
{ name:'', field:'edit/delete/startnow' , width: "70",
cellTemplate:' <img ng-click="grid.appScope.edit(row, $event)" src='Images/edit.gif' /> <img src='Images/delete.gif' ng-click="grid.appScope.delete(row, $event)" /> <img src='Images/startnow.gif' ng-click="grid.appScope.startNow(row, $event)" />' },
{ name:'Jobname', field: 'Jobname', width: "297"},
]
};
In the controller:
$scope.edit = function(row, $event) {
var element = $event.currnetTarget;
var rowObj = row.entity[your-data-object];
}

Is there a way for me to push my referenced object into an array?

I want to push each object into an array when it is clicked. I am able to get a reference of each individual object but I'm not able to push the object into an array. It tells me push is not a function. I've spent so much time trying to figure this out. Can someone point me in the right direction?
angular.module('app', []);
angular.module('app').controller("MainController", function() {
var vm = this;
vm.ordered = {};
vm.menu = [{
title: 'Pizza',
type: 'entree',
favorite: true,
price: 10
}, {
title: 'Tacos',
type: 'entree',
favorite: false,
price: 5
}, {
title: 'Onion Rings',
type: 'app',
favorite: false,
price: 2
}, {
title: 'Ice Cream',
type: 'dessert',
favorite: false,
price: 11
}, {
title: 'Mac n Cheese',
type: 'app',
favorite: false,
price: 7
}, {
title: 'Salad',
type: 'salad',
favorite: true,
price: 4
}];
}).directive('section', function() {
return {
restrict: 'E',
link: function(scope, element) {
scope.ordered = {};
element.bind('click', function(event) {
console.log(scope.item);
scope.ordered.push(scope.item);
});
}
};
});;
.left {
float: left;
width: 50%;
}
.right {
float: left;
width: 50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="app" ng-controller="MainController as main">
<div class="left">
<h2>Lists One</h2>
<section id="{{item.id}}" ng-repeat="item in main.menu | filter:main.searchInput | orderBy:main.order.key:main.order.reverse">
<strong>{{item.title}} </strong>
<span>$ {{item.price}}</span>
</section>
</div>
<div class="right">
<h2>Lists Two</h2>
<section id="{{item.id}}" ng-repeat="item in main.ordered | filter:main.searchInput | orderBy:main.order.key:main.order.reverse">
<strong>{{item.title}} </strong>
<span>$ {{item.price}}</span>
</section>
</div>
Change scope.ordered = {}; to scope.ordered = [];

KendoUI Grid does not invoke update function in popup mode with editable template

I'm using a Kendo UI Grid with AngularJS. The grid has a 'popup' mode editable kendo template. The grid invokes the create, destroy & delete functions; however the update function won't get called. Strangely when I change the edit mode to 'inline', the update function is called. Below are the code snippets from my application :
Main UI Grid:
<div class="container-fluid">
<kendo-grid style="margin-top: 2em" k-options="ctrl.fundGridOptions" k-scope-field="kgrid" id="myGrid"></kendo-grid>
</div>
Edit Template:
<script id="edit-template" type="text/x-kendo-template">
<div class="container">
<div class="well">
Fund :
<select kendo-drop-down-list k-options="ctrl.fundOptions" style="width: 130px;" ng-model="dataItem.GenevaId"></select>
<!--<select kendo-drop-down-list k-data-source="ctrl.funds" style="width: 130px;" ng-model="dataItem.GenevaId"></select>-->
NAV Change Threshold
<input kendo-numeric-text-box k-min="0" k-max="100" k-ng-model="value" style="width: 60px;" ng-model="dataItem.NAVThreshold" />
NAV Source
<select k-data-source="ctrl.navSources" kendo-drop-down-list k-option-label="'-Select-'" style="width: 130px;" ng-model="dataItem.NAVSource"></select>
Frequency
<select k-data-source="ctrl.frequencyList" kendo-drop-down-list k-option-label="'-Select-'" style="width: 130px;" ng-model="dataItem.Frequency"></select>
Type
<select k-data-source="ctrl.typeList" kendo-drop-down-list k-option-label="'-Select-'" style="width: 130px;" ng-model="dataItem.Type"></select>
</div>
<div kendo-grid="ctrl.currencyKendoGrid" style="margin-top: 2em" k-options="ctrl.currencyGridOptions"></div>
</div>
</script>
Grid Options:
ctrl.fundGridOptions = {
dataSource: {
transport: {
update: function (options) {
DataSvc.updateFund(e.data).then(function (response) {
e.success(e.data);
});
},
},
schema: {
model: {
id: "FundId",
fields: {
FundId: { type: "number", editable: false, nullable: true },
GenevaId: { type: "string", editable: true },
NAVThreshold: { type: "number", editable: true },
NAVSource: { type: "string", editable: true },
Frequency: { type: "string", editable: true },
Type: { type: "string", editable: true },
}
}
},
},
sortable: true,
columns: [
{ field: "GenevaId", title: "Fund Name" },
{ field: "NAVThreshold*100", title: "NAV Threshold", template: '#=kendo.format("{0:p}", NAVThreshold)#' },
{ field: "NAVSource", title: "NAV Source" },
{ field: "Frequency", title: "Frequency" },
{ field: "Type", title: "Type" },
{ command: ["edit", "destroy"], title: " " }
],
detailTemplate: kendo.template($("#detail-template").html()),
detailInit: function (e) {
kendo.bind(e.detailRow, e.data);
},
dataBound: function (e) {
var grid = e.sender;
if (grid.dataSource.total() == 0) {
var colCount = grid.columns.length;
$(e.sender.wrapper)
.find('tbody')
.append('<tr class="kendo-data-row"><td colspan="' + colCount + '" class="no-data">Sorry, no data :(</td></tr>');
}
},
editable: {
mode: "popup",
template: kendo.template($("#edit-template").html()),
window: {
title: "Edit Fund Details",
animation: false,
height: "600",
width: "1200"
}
},
edit: function (e) {
if (e.model.Currencies)
ctrl.currencyKendoGrid.dataSource.data(e.model.Currencies);
},
toolbar: [
{
name: 'create',
text: 'Add Fund',
}],
};
Could anyone help me understand the reason why the 'update' function won't be called in 'popup' mode, but gets called in 'inline' mode ? Appreciate any responses in advance.
I know this is question old, but I came across it searching for an answer. I think the issue might be that your (and my) edit template uses ng-model binding to edit the dataItem ie we're using angularjs. This doesn't actually seem to change the dirty property on the dataItem. I solved the issue by using ng-change on each control. It's a pain, but seems to work.
<input id="Title" type="text" class="k-textbox" ng-model="dataItem.Title" ng-change="dataItem.dirty=true"/>

Using AngularJS and KendoGrid

I am learning AngularJS and trying to use the Telerik KendoGrid in a directive. I have a directive that that will access a service and get some data. Part of the data will be used to populate an observable array in the directive. The html that is associated to that directive has another directive within it that will create a kendoGrid that should be editable. When I click on the update button I get an undefined error and the grid data disappears.
I define my array as follows:
$scope.currentData.event.submissionDates = new kendo.data.ObservableArray([
]);
and on success of call push the data into the array.
the grid is called as follows in the html:
<submission-grid class="grid-16" event="currentData.event" ng-show="currentData.event.eventID"></submission-grid>
This directive calls the following html file:
<div kendo-grid="grid"
k-columns="gridColumns"
k-selectable="true"
k-on-change="selected = data"
k-options ="mainGridOptions "
k-editable ="{'mode': 'inline', 'update': 'true'}"
and the backing js is:
(function () {
angular.module('app.submissionGrid', [])
.directive('submissionGrid', function () {
var ctrlr = function ($scope) {
$scope.gridColumns = [{
field: "SubmissionDueDate",
title: "Due Date",
format: "{0:MM/dd/yyyy}",
width: "100px"
}, {
field: "Source",
title: "Agency",
width: "100px"
}, {
field: "SubmissionFiledDate",
title: "Filed Date",
format: "{0:MM/dd/yyyy}",
width: "100px"
}, {
field: "SeverityCategory",
title: "Severity Category",
width: "100px"
}, { command: ["edit", ], title: " ", width: "200px" }
];
$scope.mainGridOptions = {
dataSource: {
data: $scope.event.submissionDates,
schema: {
model: {
id: "ReportId",
fields: {
SubmissionDueDate: { type: "string" },
Source: { type: "string" },
SubmissionFiledDate: { type: "string" },
SeverityCategory: { type: "string" }
}
}
},
}
}
}
return {
restrict: 'E',
templateUrl: 'App/Event/SubmissionGrid/submissionGrid.html',
controller: ctrlr,
transclude: false,
scope: {
event: '='
}
};
})
})();
Any advice would be appreciated.

Resources