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

Passing arguments from grid event

4 Answers 3049 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kai
Top achievements
Rank 1
Kai asked on 28 Sep 2012, 04:00 PM
Is there a way to pass parameters from the grid Events
Can I do something like
.Events(evt=>evt.DataBound("FindNull, MyGridName"))

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 03 Oct 2012, 10:45 AM
Hi Kai,

 
Currently sending additional parameters to the event handler is not supported, however please note that
in the handler you can access the caller by using the "this" keyword:

function dataBoundEvent(e) {
    var gridSender = this;
    //Your custom code here
}


Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Phil
Top achievements
Rank 1
answered on 22 Jan 2017, 09:43 AM

It's rather atrocious that Telerik still hasn't supported passing additional parameters in the event handler 5 years later - but it turns out that there's a simple workaround, kindly identified by a Sergey T on Stackoverflow, which works well and isn't too fragile:

-----------------------
I would suggest passing the target grid id as an argument to your function. Example: .Events(events => events.Error("function(args){telerikGridAraxErrorhandler(args,'myGridId');}"))
-----------------------

In other words, rather than passing a string containing the error handling function name, pass a string containing a closure which is called by the Telerik control, and which in turn calls your event handler with your additional parameter(s), which is 'myGridId' in the above example.  

 

0
AppDev
Top achievements
Rank 1
answered on 04 Aug 2017, 01:54 PM

THANKS PHIL this worked perfectly

 

1
George
Top achievements
Rank 1
answered on 02 Oct 2018, 12:35 PM

Another Thank you Phil - that is SUPER helpful! Thanks again.

For future people that find this - here is the Stackoverflow question/answer:

https://stackoverflow.com/questions/20886651/get-a-reference-to-kendo-grid-from-inside-the-error-handler/28591103#28591103

Tags
Grid
Asked by
Kai
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Phil
Top achievements
Rank 1
AppDev
Top achievements
Rank 1
George
Top achievements
Rank 1
Share this question
or