Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
WebDataGrid- Pass Custom Arguments to Client Side Events
posted

Hello,

               My asp.net application runs in mulitple user controls rendered under a parent web page. Each user control has web datagrid rendered inside it and the web datagrid uses client side events. Some of these client side events uses 

$find("<%= Me.grdDataTable.ClientID%>") to fetch the WebDataGrid dom in the user control.

Going forward I would like to manage all the client side events and custom javascript functions inside one javascript file which is included in the parent page instead of at user control level. I am planning to pass grdDataTable.ClientID to each of these client side events and custom javascript functions, so that the $find can use this client id input argument to find the appropriate dom element.

But I am seeing the infragistics client side events are using specific arguments as input to it as in eg:

  • RowSelection_Changed(webDataGrid, evntArgs)
  • RowEditing_EnteringEditMode(sender, e)
  • EditingEvents_RowAdding(sender, e)
  • ClientEvents_Initialize()

Is there a way to pass Client Id to these event methods as an input argument?

Thanks,

Aravind

Parents
  • 130
    Offline posted

    Hello Aravind,

    If I understood correctly you have multiple WebDataGrids hosted in different user controls. And you want to reuse the event handlers by placing them in a common place - a single javascript file included in the parent page.

    If the above assumption is correct you could put all event handlers in this single file and subscribe each instance of the WebDataGrid to that event handlers. But you can't change the arguments of the event handlers. Events are emitted by the WebDataGrid control so the user could execute some custom action at a given point of the component's lifecycle. Event arguments are hardcoded in component's source code and usually contain the sender (in our case this is the WebDataGrid's instance emitting the event) and some extra argument useful in the current event scenario. If you attach a handler having different signature than the event it won't be executed or the event handler arguments won't be properly populated.

    Having that said I don't think you could accomplish what you want by passing the ClientID to the event arguments.

    I could suggest you to create a global dictionary for your application to store the ClientIDs. The key of the dictionary could be the grid instance and value of the dictionary will be the ClientID corresponding to that grid's instance. When you populate the user controls you could fill the dictionary with information. When an event is fired and the appropriate event handler in your common javascript code is executed you could find the ClientID by searching into that dictionary using the sender argument as key. Sender argument will contain the current instance of the WebDataGrid which emitted the event.

    I hope the tip I gave you will help you accomplish what you want to do.

Reply Children