Hy,
i cant find the best way to validate dependent fields within the popup dialog from Kendo.
Here are my grid options:
$scope.gridOptions = { dataSource: data, selectable: "row", language : $translate.use(), pageable: true, editable: { mode: "popup", template: kendo.template($("#orderEditTemplate").html()) }, save: function(e) { if(e.model.OrderStateId == 9) { if(!e.model.ErrorReason) { $scope.error = "Reason!!!"; e.preventDefault(); } } }, columns: [ { field: "CreatedOn", title: $translate.instant("ADMIN.ORDERS.GRID.CREATEDON"), template: "#= moment(CreatedOn).format('L LT') #" }, { field : 'TotalAmount', template : "{{ dataItem.TotalAmount | ccurrency:dataItem.Currency }}", title: $translate.instant("ADMIN.ORDERS.GRID.TOTALAMOUNT") }, { field: "Description", title: $translate.instant("ADMIN.ORDERS.GRID.DESCRIPTION") }, { field: "OrderStateId", title: $translate.instant("ADMIN.ORDERS.GRID.STATUS"), template : '{{ dataItem.OrderStateId | orderStatus }}' }, { command: "edit", title: " ", width: "100px" } ]};This is my Popup Template:
<script type="text/x-kendo-template" id="orderEditTemplate"> <div> <div class="alert alert-danger" ng-show="error"> {{error}} </div> <div class="form-group"> <label>PaymentState</label> <select kendo-drop-down-list k-on-change="dataItem.dirty=true" k-data-text-field="'Text'" k-data-value-field="'Value'" k-data-source="orderStates" ng-model="dataItem.OrderStateId"></select> </div> <div class="form-group" ng-show="dataItem.OrderStateId == 9"> <label>Reason:</label> <textarea class="form-control" rows="3" ng-model="dataItem.ErrorReason"></textarea> </div> </div></script>
What i woud like to to is. If the OrderStateId is set to 9, the ErrorReason field is required. If the OrderStateId is set the anything else, your good to go without ErrorReason. My Problem ist that my error-Alert in the Popup is never going to be displayed. I don't know why, but could it be possible that inside the popup its a different scope?
What is the best way with Kendo and Angular to Validate such things?
Best Regards
Dominik