In my AngularJS app, I'm using a Kendo grid with an edit template. This way when a user clicks on the EDIT button, I can control the editable fields in the modal popup.
Now in this edit template, I have added some custom functionality; that is, a simple "Add" option. This Add option will call into a function within my controller code. All good so far.
The problem is: when I click on the "Add" link, I cannot get access to the fields within the controller by way of dataItem.fieldName
.
Here's my HTML :
<div class="col-lg-5">
<span id="userKriGrid"
kendo-grid="settings.userRiskMsrGrid"
k-data-source="settings.userRiskMsrGridDS"
k-options="settings.riskMsrGridOptions"
k-rebind="settings.riskMsrGridOptions">
</span>
</div>
and the grid settings within my js controller:
settings.riskMsrGridOptions = { // Kendo grid settings
selectable: true,
columns: [
{ field: "id", width: "10px", hidden: true },
{ field: "name", title: "Risk Measure", width: "5px", },
{ field: "kri_group", title: "Cube", width: "20px", hidden: true },
{ field: "kri", title: "Result Vector", width: "20px", hidden: true},
{ field: "kri_alias", title: "KRI Name", width: "20px", hidden:true },
{ field: "aggreg_formula", title: "KRI Expression", width: "35px", hidden: true },
{ command: [{ name: "edit", text: '' }, { name: "destroy", text: '' }], title: "Edit", width: "5px" }
],
editable: {
mode: "popup",
template: kendo.template($("#editorTemplate").html()) // loaded up in index.html
},
edit: function (e) {
var window = e.container.data("kendoWindow");
window.title("Risk Measure Edit");
}
};
And I'm loading an external template (i.e. http://docs.telerik.com/kendo-ui/framework/templates/load-remote ).
Please note the ng-click
event in the button calls into settings.addToDefRiskMsr(e)
<script id="editorTemplate" type="text/x-kendo-template">
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">Risk Measure</label>
<div class="col-md-3">
<input id="textinput" ng-model="dataItem.name" class="form-control input-md" type="text" >
</div>
<div class="col-md-2"> <!-- ADD BUTTON HERE !!! -->
<button type="button" class="btn btn-default" ng-click="settings.addToDefRiskMsr(e)" >
<span title="add to Risk Measure grid" class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span> Add to DRM
</button>
</div>
</div>
</fieldset>
</form>
</script>
Again, the template code above uses dataItem.fieldName
to pull the field I want to the user have edit access to.
Now how do I get access to that field within my controller ? dataItem.name
DOES NOT WORK !
settings.addToDefRiskMsr = function (e) {
var riskMeasureName = dataItem.name; // NOT WORKING !!!
your advice is appreciated.
regards, Bob }
$scope.dataItem.name
is the item you are trying to get? – scniroctrl.dataItem.myfield
. But when I try to use the same inside my controller, there's nodataItem
at all! – AsGoodAsItGets