Grid in ajax loaded partial view

Feb 14, 2014 at 10:51 PM
Hey guys

I'm loading a partial view via ajax which contains a Grid.Mvc grid. Grid loads up, is populated and look great. There is also a similar grid on the originally loaded page which is working fine.

I'd like to make use of the javascript functionality of the grid to handle row selection but an error is thrown when I attempt to reference the grid,
pageGrids.myGrid.onRowSelect(function (e) {
    // action
});
Gives the error -
Uncaught TypeError: Cannot call method 'onRowSelect' of undefined

Any thoughts on how I might get this going ? Do I need to initialise the grid explicitly in javacript somehow ?

Thanks!
Coordinator
Feb 15, 2014 at 9:17 AM
Hi,

Yes, if you load grid layout via ajax and paste to the DOM - you need explicitly init grid client functionality by calling:
var grid = $("#mygridcontainer").gridmvc();
grid.onRowSelect( ... )
Feb 19, 2014 at 11:21 AM
Bukharin wrote:
Hi,

Yes, if you load grid layout via ajax and paste to the DOM - you need explicitly init grid client functionality by calling:
var grid = $("#mygridcontainer").gridmvc();
grid.onRowSelect( ... )
Hi,

Can you tell me where exactly I have to put this code?
I tried in both views but with no success.

Thanks!
Coordinator
Feb 22, 2014 at 10:02 AM
Where you make an ajax call and modify DOM tree?