views:

61

answers:

2

I'm using MVC 2 and loading a partial view via AJAX which contains my jqGrid. The problem is that my OnSelectRow event only fires once if I have it in an external .js file. Is it possible to use the jQuery live to bind to the OnSelectRow? I can only see how to bind the OnSelectRow in the options for the jqGrid?

Thanks for the help, Ciaran

A: 

It seems to me you will find the answer on your question in http://stackoverflow.com/questions/3148320/add-an-event-handler-to-jqgrid-after-instantiation/3149534#3149534. Live binding is nothing more as the usage of setGridParam method with onSelectRow event handle.

Oleg
I tried this and it works up until the point when I try to pass in a parameter. Is it possible to pass in a parameter?
Click Ahead
Inside of `onSelectRow` event you can call any function with parameters, but parameters of the function should be visible of cause. It's more the question how one can use and define functions (and closures) in javascript and visibility (variable scope). See http://stackoverflow.com/questions/111102/how-does-a-javascript-closure-work or search in internet. If you also post your code example it would be probably possible to fix the code.
Oleg
+1  A: 

I resolved this issue in the end by using the following:

$('#gridTable').jqGrid({
...
, onSelectRow: function (id) { MyMethod(Param1,Param2,id); }
... })

The problem was I wasn't passing the parameters into my method correctly. The above worked for me.

Ciaran

Click Ahead