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

Prevent open or close in onOpen and Onclose Event

8 Answers 203 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Shahram
Top achievements
Rank 1
Shahram asked on 16 Sep 2020, 03:00 PM

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

Sort by
0
Martin
Telerik team
answered on 18 Sep 2020, 12:04 PM

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/.

0
Shahram
Top achievements
Rank 1
answered on 19 Sep 2020, 04:34 PM

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?


0
Martin
Telerik team
answered on 23 Sep 2020, 05:31 AM

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/.

0
Shahram
Top achievements
Rank 1
answered on 25 Sep 2020, 05:05 PM
Dear Martin
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);
            });
          
        });
0
Martin
Telerik team
answered on 29 Sep 2020, 02:02 PM

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/.

0
Shahram
Top achievements
Rank 1
answered on 02 Oct 2020, 09:15 AM

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.

0
Shahram
Top achievements
Rank 1
answered on 02 Oct 2020, 04:14 PM

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

0
Martin
Telerik team
answered on 05 Oct 2020, 03:32 PM

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).

Tags
DropDownList
Asked by
Shahram
Top achievements
Rank 1
Answers by
Martin
Telerik team
Shahram
Top achievements
Rank 1
Share this question
or