Hi ,
I have tried to use a custom validation on the schema/model/fields but is not quite working for me.
Instead I am trying to use grid edit event which is giving me more flexibility.
Example
dojo.telerik.com/aJeXE
How could I display validation popup message from edit event?
I have tried to use a custom validation on the schema/model/fields but is not quite working for me.
custom: function (input) { if (input.is("[name='LogicalName']") && input.val() != "") { $http.post("odata/Entities/IsNameUnique", { logicalName: input.val() }).success(function (data, status, headers, config) { if (!data.value) { input.attr("data-custom-msg", "Name is not unique"); return false } return true;}); } }Instead I am trying to use grid edit event which is giving me more flexibility.
Example
dojo.telerik.com/aJeXE
How could I display validation popup message from edit event?
5 Answers, 1 is accepted
0
Hi Wit,
The Grid's edit event could be used to get the instance of the built-in Validator, extend its options with the new validation rules and messages and apply them using the setOptions method. For example:
Regards,
Alexander Popov
Telerik
The Grid's edit event could be used to get the instance of the built-in Validator, extend its options with the new validation rules and messages and apply them using the setOptions method. For example:
function onEdit(e) { var validator = e.container.getKendoValidator(); var options = validator.options; var extendedOptions = kendo.deepExtend(options, { rules: { myRule: function (input) { /*....*/ return false; } }, messages: { myRule: "Custom validation message" } }); validator.setOptions(extendedOptions);}Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Wit
Top achievements
Rank 1
answered on 22 Sep 2014, 02:12 PM
Hi Alexander,
That looks very promising. I am using typescript in my project and kendo.deepExtend is not recognised. Would you have any suggestions how I could fix it?
Thank you
Wit
That looks very promising. I am using typescript in my project and kendo.deepExtend is not recognised. Would you have any suggestions how I could fix it?
Thank you
Wit
0
Accepted
Hello again Wit,
Manually extending the options object should also work. For example:
Regards,
Alexander Popov
Telerik
Manually extending the options object should also work. For example:
function onEdit(e) { var validator = e.container.getKendoValidator(); var options = validator.options; options.rules.myRule = function(){/*...*/}; options.messages.myRule = "message"; validator.setOptions(options);}Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Wit
Top achievements
Rank 1
answered on 22 Sep 2014, 02:45 PM
Hi Alexander,
Should that prevent me from moving to the next cell when input validation failed? Or should I manually cancel event?
Thank you
Should that prevent me from moving to the next cell when input validation failed? Or should I manually cancel event?
Thank you
0
Hi Wit,
That is correct - if the validation fails the user should not be able to leave the cell.
Regards,
Alexander Popov
Telerik
That is correct - if the validation fails the user should not be able to leave the cell.
Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!