adding onrowselect function

Jan 26, 2015 at 3:37 PM
In the view based on a condition, I am displaying a grid. For example.
if(!Names.IsInactive)
@Html.Grid(Model.Cdas, GridRenderOptions.Create("gridNames")).Named("gridNames").Columns(columns =>
...............

}
In my jquery dom ready function. I want to add the following function if Names grid is in the DOM. For example.
var names = document.getElementById('names');
if(names)
{
 pageGrids.gridNames.onRowSelect(function (e) {
....
}
When the grid is displayed in my browser, and I click on a row, nothing happens. Any ideas why the onRowSelect function is not executing. It works fine if I remove the condition base logic. I am not sure how to add this onRowSelect function to the dom based on a condition. Any help would be appreciated.
Jan 27, 2015 at 6:49 PM
Nevermind. Looking at the source i realized that the grid is using data-gridname property. I was able to reference the grid by using the data("gridname") jquery method.