jQuery UI Widgets › Forums › Grid › link in a cell
This topic contains 5 replies, has 2 voices, and was last updated by gisernia 12 years, 2 months ago.
-
Authorlink in a cell Posts
-
I need to put a link in a cell
scenario
set in a cell the value
THE_LINK=
<a href="?module=xxxx&applettype=yyyy&record=ID">fieldvalue</a>
where ID is in:
var source =
{
datatype: “json”,
datafields: [
{ name: ‘ID’},
{ name: ‘FST_NAME’},
{ name: ‘LST_NAME’}],
and columns are:
columns: [
{ text: ”, datafield: ‘FST_NAME’, width: 200, cellsrenderer: THE_LINK},
{ text: ”, datafield: ‘LST_NAME’, width: 180 }]
How can I do?
thanks giulio
Hi giulio,
Here’s a sample with Column with Links: customcolumn.htm.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comyes,
the sample is ok,
but how can I calll the field ID inside the renderer function?thanks
GiulioHi Giulio,
To get the row’s id, you may use the “getrowid” method. It accepts as parameter the row’s index which is passed to the “cellsrenderer” callback function used for rendering the links.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI use this function
var linkrenderer = function (row, column, value) {
if (value.indexOf(‘#’) != -1) {
value = value.substring(0, value.indexOf(‘#’));
}var format = { target: ‘”_blank”‘ };
var html = $.jqx.dataFormat.formatlink(value, format);return html;
and it’s ok to retrieve column data.
But id is not in the row, it’s only in the source
var source =
{
datatype: “json”,
datafields: [
{ name: ‘id’},
{ name: ‘FST_NAME’},
{ name: ‘LST_NAME’},
],and in grid definition I have:
columns: [
{ text: ”, datafield: ‘FST_NAME’, width: 200, cellsrenderer: linkrenderer},
{ text: ”, datafield: ‘LST_NAME’, width: 180 },
]I’d like to retrieve the id value!!
thanks
GiulioRESOLVED:
this is the linkrender function:
var linkrenderer_accounts = function (row, column, value) { if (value.indexOf('#') != -1) { value = value.substring(0, value.indexOf('#')); } href = source.records[row].ID; var html = "<a href=\"?module=accounts\&applettype\=baseview\&ret_module=accounts\&ret_applettype\=listview\&record="+href+"\">"+value+"</a>"; return html; };
-
AuthorPosts
You must be logged in to reply to this topic.