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

[Solved] When can I call add_gridCreated?

1 Answer 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeanne
Top achievements
Rank 1
Jeanne asked on 12 Apr 2013, 03:51 PM
I'm using a radGrid in a user control. The user control has a client-side API (so it can be used more than once on the same page). Due to this, I cannot specify a client-side OnGridCreated event handler declaratively, since the same function would be called for multiple occurrences of the grid. In my client-side component's initialize event the grid does not exist yet, so I cannot attach handlers there, but if I go for the pageLoad event, the grid has already been created, and the gridCreated event fired, so it's too late to attach to it. Any suggestions on how/when I can attach this event successfully?

1 Answer, 1 is accepted

Sort by
0
Jeanne
Top achievements
Rank 1
answered on 12 Apr 2013, 07:24 PM
After more research, my conclusion is: you can't do it in this scenario. There simply is no spot where the grid component exists but the OnGridCreated event has not yet fired where I can attach to the gridCreated event! Instead I will just have to put my code (in this case to hide/show buttons on the grid's title bar) someplace else. The pageLoad event will work fine for that.
 
Alternatively, I found that by using ScriptControlDescriptor.AddComponentProperty("grid", myGrid.ClientID) to add a reference to the radGrid component to my client control the order of events on the client is changed significantly. In this case the grid component, and any other components my component includes, are actually created before my component's initialize event is called. Therefore I can access the grid component in my component's initialize event instead of waiting for the pageLoad event.
Tags
Grid
Asked by
Jeanne
Top achievements
Rank 1
Answers by
Jeanne
Top achievements
Rank 1
Share this question
or