Use One OnRequestEnd event handler for multiple grids

2 posts, 0 answers
  1. Sam
    Sam avatar
    13 posts
    Member since:
    Aug 2015

    Posted 20 Apr Link to this post

    I have a view with 12 different kendo grids. I would like to use just one onRequestEnd event handler for all 12 of the grids.  Is there a way to identify which grid initiated the call that fired the event?  I need the supplied "e" properties, but I need to identify which grid caused the event as well.
  2. Tsvetina
    Admin
    Tsvetina avatar
    2076 posts

    Posted 21 Apr Link to this post

    Hi Sam,

    Since the requestEnd is an event of the DataSource, it contains no information about the Grid that triggered the request. Furthermore, as the DataSource itself can be shared between multiple Grids, it does not have a property that points to the Grid that uses it.

    As a work around, you can consider adding an event handler for the Grid operations that can fire DataSource events, e.g. sort, filter, saveChanges and store e.sender (the Grid instance) in a variable that you can use later in requestEnd. If you don't have other logic to execute, related to the given events, you can use a single event handler function for all events in all Grids:

    var currentGrid;
     
      $("#grid").kendoGrid({
        sort: storeGridReference,
        filter: storeGridReference
      });
     
    function storeGridReference(e) {
        currentGrid = e.sender;
    }


    Regards,
    Tsvetina
    Telerik by Progress
    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.
Back to Top