I want auto open on focus for all of dropdownlists in my page.
Here is a sample for Jquery Version:
https://www.telerik.com/forums/how-to-open-dropdownlist-on-focus
I have modified this code for MVC , But there is a problem,
MVC version of dropdownList do not send event as function parameter (e) and I do not know how to do preventDefault.
any Help or suggestion?
8 Answers, 1 is accepted
Hello Shahram,
Attached you will find a small MVC project with the code from the forum thread you shared. Could you please modify it to reproduce the issues you are experiencing? I will be able to test it and help you resolve the problem.
Looking forward to your reply.
Regards,
Martin
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Thank you Martin.
Your sample code works as excepted. I found some JS problem else where and now my code works too.
Is it possible to do same for dropdownlists on Kendo grid popup editing template?
Hello Shahram,
The shared approach should work just as good in the scenario you described. Still, if you are experiencing any sort of issues, please do not hesitate to get back to us. I would appreciate if you could share a project where I can observe them.
Regards,
Martin
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
I wan unable to attach onfocus and click events to dropdownlists on a Template page.
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("LadeAssignmentAdminTemplate")
I am using this code for normal pages .But I don't know what to do for a template page .
var PreventAction = {};
var itIsopen = {};
$(function () {
$("[data-role=dropdownlist]").each(function (e) {
var widget = $(this).getKendoDropDownList()
id = widget.element.attr('id');
PreventAction[id] = false;
itIsopen[id] = false;
widget.wrapper.on("focus", function (x) {
id = widget.element.attr('id');
if (PreventAction[id] && itIsopen[id]) {
widget.close();
console.log("Closed on focus", id);
PreventAction[id] = false;
} else {
widget.open();
console.log("opend on focus", PreventAction);
console.log("and", itIsopen);
}
});
});
$('.k-list-container').on('click', '.k-list-optionlabel, li', function (e) {
var clickedId = $(e.currentTarget).closest('.k-list-container').attr('id');
clickedId = clickedId.substring(0, clickedId.indexOf('-'));
var list = $("#" + clickedId).getKendoDropDownList();
list.close();
console.log("Closed on click", clickedId);
});
});
Hello Shahram,
Could you please share what exactly is not working as expected when placing the code in a template? I would appreciate if you could share a small runnable example where I can observe the problem and directly debug it. I will then be happy to propose a solution.
Looking forward to your reply.
Regards,
Martin
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Ok I will try to Create a simple project .
But Before if, I ams sure I do some thing wrong.Is there any demo project for that? If I put code in my "LadeAssignmentAdminTemplate.cshtml" file , It is Ignored completly,and when I copy code to Cshtml file that contains grid , onOpen and onclose are assigned, but focus function is not attached.
Ok .Done!
I figuredout I must use onEdit event of grid for assiging onfocus function to dropdownlist and also kendoWindow activate event for setting focus on first of them
Thanks
Hello Shahram,
I am glad that you were able to resolve the problem.
Feel free to get back to us whenever you have further questions.
Regards,
Martin
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).