Unplanned
Last Updated: 08 Jul 2022 13:57 by ADMIN
Brandon
Created on: 16 Jun 2022 22:58
Category: Grid
Type: Feature Request
0
GridInitialized event

Hi Team,

I'd like to request a built-in event before the Grid starts a Read action.  

Thank you!

5 comments
ADMIN
Angel Petrov
Posted on: 08 Jul 2022 13:57

Hi,

Thank you for clarifying. Indeed having an event to fire after everything in the grid is initialized will do the job. I have altered the name of the request to better match the requirements.

Regards,
Angel Petrov
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Brandon
Posted on: 01 Jul 2022 14:04

Is there anyway I can change the title and description of this request.  It was done on my behalf and the title is not really accurate and there isn't really a description.

If I had to re-do it I would call it something like the GridInitialized event.  This event would only ever fire once in the life cycle of a grid and would fire even if the grid is not set to autobind. 

I figured the first thing you'd come back with would be the documents OnReady event.  The problem is that if you have a foreign key that is get's it's data via ajax then you can't rely on that event as those items are loaded asynchronously and the grid isn't completely initialized until the last foreign key is set up.

I'd also like to add clarity about what is being changed. In this case there are no parameters to the AJAX call so the parameterMap function doesn't apply, although I have used it elsewhere.  What is changing is what you actually see on the grid.  Someone clicking a column to sort it or dragging it up to group by it.  You can even click the column menu and add a custom filter.  Every time the end user makes one of these changes the state of the grid is saved.  When you reload the screen it gets the last saved state and loads it.  This grid has sever operations turned on which affects how the data is loaded on the server and is why I wanted the state to be loaded prior to it fetching data from the server.

There have been other times I thought something like this would be nice when requestStart isn't a good option.  The requestStart event runs every time data is loaded.  When you have server operations turned on this can be a lot.  I know the biggest thing getting in my way is the ajax foreign keys but lately I've been trying to do most all my foreign keys that way for performance reasons.  Hopefully this helps you understand what I'm after better.

ADMIN
Angel Petrov
Posted on: 30 Jun 2022 13:37

Hello,

I am not sure what settings exactly should be changed but it seems that the parameters for the initial requests should be altered. If that is the case on can also use the parameterMap function and only initially alter the parameters. This function will also call on every read, updated and etc but using a flag you can apply modifications just once. Generally all the events should fire always and having one-time events does not seem a good fit. That said I would recommend sticking to the workaround or altering it(as suggested) to achieve the desired goal.

Regards,
Angel Petrov
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Brandon
Posted on: 23 Jun 2022 13:55

This was created on my behalf and I probably should have added a little more detail.  After speaking with the support person I actually came up with a "work around" using the requestStart event.  The biggest issue here is I only want the event to run once when the grid first loads.  The purpose is to make any necessary changes with sorting, filtering and grouping which would all affect the request for data.  If you had the event in question autobind would be set to false which means you couldn't use request start anyways.  I would then manually kick off the read of the data so the data would be read with the appropriate settings.  Since the event would only fire when the grid is done being initialized I wouldn't have to worry about it firing again on a refresh of the data or when something changed (like sorting, filtering, or grouping) that would cause another request since the grid in question is set to do server side actions.

My current workaround is to use the request start as you mentioned but I do a preventDefault to stop the event from happening. I then unbind the event, make my changes, and then manually call read.  I think it would be so much nicer if I didn't have to jump through all the hoops of binding, preventing, and unbinding the event.  This would get even more complicated if I needed to use the request start event for something else.

I bet about now you are probably asking yourself why I even need to make changes on load.  The reason is this screen allows people to modify the grid and save the state so the next time you load the screen you can come back to where you were.  When you come back to this page it initializes the grid with the default settings (those set in the configuration step) and uses the event to apply the saved state it wants to get back too. Hopefully all of this helps make this request make more sense.

ADMIN
Angel Petrov
Posted on: 23 Jun 2022 10:41

Hello,

Generally the grid's datasource has a requestStart event that can be used for this purpose. Here is a dojo which demonstrates it in action. Is there a scenario in which this event cannot fullfil.

Regards,
Angel Petrov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.