Passing arguments from grid event

5 posts, 0 answers
  1. Kai
    Kai avatar
    25 posts
    Member since:
    Jul 2012

    Posted 28 Sep 2012 Link to this post

    Is there a way to pass parameters from the grid Events
    Can I do something like
    .Events(evt=>evt.DataBound("FindNull, MyGridName"))
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2206 posts

    Posted 03 Oct 2012 Link to this post

    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!
  3. Phil
    Phil avatar
    13 posts
    Member since:
    Mar 2014

    Posted 22 Jan 2017 Link to this post

    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.  

     

  4. AppDev
    AppDev avatar
    7 posts
    Member since:
    Mar 2015

    Posted 04 Aug 2017 Link to this post

    THANKS PHIL this worked perfectly

     

  5. George
    George avatar
    3 posts
    Member since:
    Jun 2018

    Posted 02 Oct 2018 in reply to Phil Link to this post

    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

Back to Top