Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by scott bradley on Jan 15, 2010 08:08
open dhtmlx forum
dhtmlxgrid link onclick event

Hi

I was wondering if there was a way to call a javascript function when a link is clicked in a grid cell?

Basically i am listing some locations in a datagrid. When a user clicks a location, a function is called which opens a marker on a Google map.


thanks
Scott
Answer posted by Alex (support) on Jan 15, 2010 09:07

Hello

in case of using link column type - you can set the function as the second parameter:

link^javascript:someFinction()

or you can  set onRowSelect event handler that is called when cell clicked:

grid.attachEvent("onRowSelect",function(rowId,columnIndex){

    /*your code here*/

})

Answer posted by scott bradley on Jan 18, 2010 07:12
Thanks Alex. The attach event works fine but ideally I wanted a link so it was clear the user was able to press. I tried the javascript:myFunction(value) as the link but i got an error saying the function wasn't defined and a blank page is opened. The function is defined in the same page as the grid and is the same one used as the onSelectRow event.
Answer posted by Alex (support) on Jan 18, 2010 07:49

Please check the sample in the grid package dhtmlxGrid/samples/01_cell_types/04_link_grid.html. Here the second row calls JS function when link is clicked. 

If the issue isn't solved, please provide the complete demo to recreate it

Answer posted by scott bradley on Jan 18, 2010 08:17
Adding -     ;^_self seems to have solved the problem

thanks
Scott