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

Use One OnRequestEnd event handler for multiple grids

1 Answer 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 20 Apr 2017, 02:47 PM
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.

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 21 Apr 2017, 12:56 PM
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.
Tags
Grid
Asked by
Sam
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or