dhtmlxgrid link onclick event


#1

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


#2


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/


})


#3

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.


#4


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


#5

Adding -     ;^_self seems to have solved the problem

thanks
Scott


#6

This helped me, thank you Scott.


#7

I have another problem with the link in grid.
My data in grid is retrieved from database, how can I created a link for a cell or a row? So far, the sample I found is XML file.
Do I need to create a link field in database?

thanks,


#8

If you are using connector for data generation, you can use beforeRender handler, to add formatting to the content ( convert plain text link to HTML link )

docs.dhtmlx.com/doku.php?id=dhtm … formatting


#9

Hi Stanislav,
Many thanks! it does sort our my problem.