I have a table that has the following data in a grid:
ID Course
2 Math
5 English
7 Science
9 History
12 Gym
What I like is for the value of ID and Course to be hyperlinks so they are clickable. When the user clicks on a given ID, I like to have an alert for that shows the given ID. When the user clicks on the Course, I like to have an alert
that shows both the ID and Course.
I am not sure how to do this. I understand there is a
showlink
but not sure how to tie it everything together.
Looking at a stackoverflow question, I can do the following:
var grid = jQuery('#list');
var sel_id = grid.jqGrid('getGridParam', 'selrow');
var myCellData = grid.jqGrid('getCell', sel_id, 'MyColName');
where MyColName would be the name of the column but not sure how to tie it altogether.
You can solve the problem in many ways. The formatter
"showlink"is oriented to create the standard HTML link<a>instead of usage JavaScriptclickevent handler. You can do use formatter"showlink"(see my very old answer) to call your custom JavaScript code, but there are better ways for implementation. For example you can use custom formatter or to useformatter: "dynamicLink"which you can find here and which I described here.The best and the most easy way which I would suggest you now is the usage of pseudo links. See the answer or another one for details.