jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Getting value from linkrenderer
This topic contains 3 replies, has 2 voices, and was last updated by Ivo Zhulev 8 years, 11 months ago.
-
Author
-
I have a linkrenderer function defined as follows which basically displays jqxGrid like below(all the cell contents are hyperlinked which is not shown below):
___________
Alphabets(s) ___________ a _________ B _________ A _________ B
var linkrenderer = function(row, column, value){ if(value.indexOf('#') != -1){ value = value.substring(0,value.indexOf('#')); } console.log("Inside Linkrenderer "+value ); var href = $('#alphabetPanel').jqxGrid('getcellvalue',row,"QuantityPerUnit"); // I got this QuantityPerUnit from some different post, don't know what to use here return "<a href='"+ href + "''>" +value + "</a>"; } $("#alphabetPanel").jqxGrid({ source: dataAdapter, width: '122', height: '170', columns: [ { text: 'Alphabets(s)', datafield: 'alphabets_text',width: 100, cellsrenderer: linkrenderer} ] });
I am trying to figure out when a user clicks on particular cell of alphabet present in the jqxGrid, how can I get the value A (when user clicks on alphabet, A).
Because my ultimate goal is to highlight alphabet A in another text content present in jqxPanel. Both grid and panel are using the same data.
Hi walker1234,
You should bind to the jqxGrid
cellclick
event.
Here is the demo:
http://jsfiddle.net/jqwidgets/HB3Cb/Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/I am using linkrenderer as mentioned in the following post by Dimitar:(Reply #45857)
http://www.jqwidgets.com/community/topic/customising-link-renderer-in-data-grid/
My linkrenderer is as follows:
var linkrenderer = function(row, column, value){ if(value.indexOf('#') != -1){ value = value.substring(0,value.indexOf('#')); } console.log("Inside Linkrenderer "+value ); var href = $('#columnPanel').jqxGrid('getcellvalue',row,"MyColumnName(s)"); console.log("href: "+href); // Outputs Undefined return "<a href='"+ value + "''>" +value + "</a>"; }
Questions:
1) I couldn’t find any documentation online which has format of this line:
`var href = $(‘#columnPanel’).jqxGrid(‘getcellvalue’,row,”MyColumnName(s)”);
`
I mean in the above line, do I need to specifycell
instead ofrow
? Is it mandatory to mentionMyColumnName(s)
?2) I am getting the value of the column in the form of link when I click it. For example , it takes me to the URL
http://localhost:8080/mywebsite/A
. Is it
necessary to usecellclick
instead ofgetcellvalue
? I mean should I change it tovar href = $('#columnPanel').jqxGrid('cellclick',row,"MyColumnName(s)");
?3) Instead of linkrenderer taking me to a link and opening a new tab in the browser, I want to stay on the same page.
I am basically looking to grab the valueA
upon the cellclick so that I can pass it whereever I want to. Please not that I would still like to show the
cell values as hyperlinks. How can I modify linkrenderer in this case?Thanks
Hi walker1234,
1. Yes you do need the column name there. The second param is the row number the third one is the column.
2@3. The
linkrenderer
function is about getting the value of the cell and making it an URL in the initialization of the jqxgrid. You want to get the
value when you click on the cell right?
Leave yourlinkrenderer
function as it. Just bind to the ‘cellclick’ event and do your stuff there. Here is a demo:
https://www.jseditor.io/?key=jqxgrid-cellrendererBest Regards,
IvojQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.