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

Multiple Event Handlers

5 Answers 400 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 01 Apr 2015, 09:35 PM
I am trying to have two javascript methods that get called when the change event on a DropDownList is raised.  If I set it up like this:

@(Html.Kendo().DropDownListFor(m => m)
...
.Events(e => e.Change("Method1").Change("Method2"))
)

Then only Method2 is called.  I can work around this a little bit by creating a third function, but then if I need the "this" variable from the event it looks like I have to pass it as a parameter to Method1 and Method2.

Is it possible to have multiple handlers registered for one event on a kendo control?

5 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 02 Apr 2015, 12:44 PM
Hello Brian,

Can this issue be related to this known problem? If so, note it has been verified and fixed shortly after our Q1 2015 release, and we apologize for the inconvenience it caused you. The fix is included in the latest internal build of the product, which is available for download from your Telerik account's > DevCraft Ultimate > UI for ASP.NET MVC product downloads section.

Please migrate to the new version and let us know whether this helps.

Kind regards,
Sebastian
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Brian
Top achievements
Rank 1
answered on 02 Apr 2015, 01:00 PM
Sebastian,

Thank you for your reply.  I don't think my situation is the same as that bug.  If I register one event handler for the change event, it works.  If I register two event handlers for the change event, only the second one is called.

Thanks,
Brian
0
Accepted
Georgi Krustev
Telerik team
answered on 06 Apr 2015, 07:26 AM
Hello Brian,

The Fluent API of the wrappers is designed to override previous setting when same method is called. In this case, the sacond Change call will override the previous one. This behavior is expected and the only to accomplish your goal is to either use 3rd function or wire the events manually using JavaScript.

Regards,
Georgi Krustev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Attila
Top achievements
Rank 2
answered on 30 Sep 2017, 10:16 PM

Hi!

I have a grid with 2 ClientTemplate columns. Each has different html input tag, so I need 2 different DataBound event handlers. is it possible? I have 2 different javascripts for uploading a file and of course 2 different action in my controller.

The columns look like this:

.Columns(columns =>
          {
              columns.Template(@<text></text>).ClientTemplate("<input type='file' id='fileUpload' name='fileUpload' />");
              columns.Template(@<text></text>).ClientTemplate("<input type='file' id='szamlaUpload' name='szamlaUpload' />");
          })

 

I guess it's not possible to use in this case a .Event(e=>e.DataBound()) property of the grid, because it only allows 1 event handler. How can I use 2 different file upload in different columns?

Thanks

0
Tsvetina
Telerik team
answered on 03 Oct 2017, 01:47 PM
Hi Attila,

You cannot add two event handlers for the DataBound event using the Fluent API but you should not need to. I would suggest opening a new thread and explaining your scenario in more detail. You should be able to handle the logic related to Upload widgets in a single DataBound event handler.

Additionally, note that it is not advisable to use ids in Kendo UI item/column templates. This results in rendering multiple elements with the same ID, which is invalid HTML and could lead to unexpected behavior. If you need the id attribute to access the uploads via JavaScript/jQuery, you can replace them with a class name specific to the upload inputs.

Regards,
Tsvetina
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Brian
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Brian
Top achievements
Rank 1
Georgi Krustev
Telerik team
Attila
Top achievements
Rank 2
Tsvetina
Telerik team
Share this question
or