This is a migrated thread and some comments may be shown as answers.

kendo-multi-select & ng-required & ng-messages

5 Answers 1039 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Werner Haltner
Top achievements
Rank 1
Werner Haltner asked on 03 May 2016, 08:27 AM

hello,

i use the "kendo-multi-select" and i want to validate required values with ng-message.
the problem is, that no one of the validation options (ng-pattern, ng-maxlength, etc) are triggered via ng-message and kendo-multi-select. even the simple "ng-required" is not accessible.

is there another solution for this issue? or a workaround i can use?

I use this one:

<select kendo-multi-select
        id="{{x.Pos}}_{{$index}}"
        name="{{x.Pos}}_{{$index}}"
        style="width:100%"
        k-ng-model="x.something.Value"
        ng-disabled="!x.Editable"
        k-data-source="x.DataSource"
        k-ng-delay="x.DataSource"
        k-value-primitive="true"
        k-rebind="x.DataSource"
        ng-required="x.Required"
        autocomplete="off"></select>


<div ng-messages="MyForm[x.Pos+'_'+$index].$error" ng-messages-multiple ng-if="MyForm[x.Pos+'_'+$index].$touched">
    <div ng-messages-include="/validationMessages.view.html"></div>
</div>

 

thank you for your help
werner

 

5 Answers, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 04 May 2016, 02:08 PM
Hello Werner,

You can use the Kendo UI Validator, as shown in the following demo:

http://demos.telerik.com/kendo-ui/validator/angular

You can find more information and API of the Validator in the following sections of our documentation:

http://docs.telerik.com/kendo-ui/api/javascript/ui/validator

http://docs.telerik.com/kendo-ui/controls/editors/validator/overview

Let us know if this helps.

Regards,
Dimiter Topalov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Werner Haltner
Top achievements
Rank 1
answered on 09 May 2016, 05:51 AM

Dear Dimiter 

I can't use the kendo validator - i must(!) use ngMessages. If it's not working with kendo - is there even a option to use both together?

Regards Werner

0
Dimiter Topalov
Telerik team
answered on 10 May 2016, 08:32 AM
Hello Werner,

In order to achieve the desired result, you will have to use ng-model instead of k-ng-model for binding. Please have in mind the following difference between the two approaches:

http://docs.telerik.com/kendo-ui/AngularJS/introduction#scope-bindings

... as well as the fact that widgets initialized from the SELECT element do not reflect changes to the model field when ng-model for AngularJS 1.4.7+:

http://docs.telerik.com/kendo-ui/AngularJS/Troubleshooting/common-issues#widgets-with-ng-model-directives-reflect-no-model-value

Let me know if you have other questions about Kendo UI.

Regards,
Dimiter Topalov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Werner Haltner
Top achievements
Rank 1
answered on 11 May 2016, 11:57 AM

Dear Dimiter

Thank you for your answer. Just to be clear and sure:

A) you said i should use ng-model 
AND 
B) you also said, that ng-model will not reflect changes to ng-model

for me, this sounds like a big contradiction. Do i understand your statement right?

Regards
Werner

0
Dimiter Topalov
Telerik team
answered on 12 May 2016, 09:06 AM
Hi Werner,

I am sorry, the last part of my previous post was not clear enough. To sum up:

 - you need to use ng-model, if you want to use other Anglular validation directives (like ng-pattern, etc.)

- there are two things you should have in mind when using ng-model instead of k-ng-model:

http://docs.telerik.com/kendo-ui/AngularJS/introduction#scope-bindings
(difference between ng-model and k-ng-model binding)

and

http://docs.telerik.com/kendo-ui/AngularJS/Troubleshooting/common-issues#widgets-with-ng-model-directives-reflect-no-model-value
(explanation why ng-model does not work properly for AngularJS versions 1.4.9 and later, along with possible solutions).

I hope this helps.

Regards,
Dimiter Topalov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MultiSelect
Asked by
Werner Haltner
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Werner Haltner
Top achievements
Rank 1
Share this question
or