jQWidgets Forums
jQuery UI Widgets › Forums › Grid › hyperlink on cell to pass id not from row
Tagged: angular grid, hyperlink, javascript grid, jquery grid, jqxGird
This topic contains 3 replies, has 2 voices, and was last updated by goldie 9 years, 2 months ago.
-
Author
-
Hello,
I’m trying to create a hyperlink in a cell that passes an ID from the source and not necessary from the row.
The link should be<a href="test.php?pid=ID">fieldvalue</a>
Here is my code
<script type="text/javascript"> var $jsquery = jQuery.noConflict(); $jsquery(document).ready(function () { var source = { datatype: "json", cache: false, datafields: [ { name: 'ID', type: 'string'}, { name: 'sName', type: 'string'}, { name: 'mgmtIP', type: 'string'} }, url: 'testData.php' }; var linkrenderer = function (row, column, value) { if (value.indexOf('#') != -1) { value = value.substring(0, value.indexOf('#')); } var href = source.records[row].ID; var html = '<a href="test.php?id='+href+'">'+value+'</a>'; return html; } var dataAdapter = new $jsquery.jqx.dataAdapter(source); // initialize jqxGrid $jsquery("#jqxgrid").jqxGrid( { width: '99%', height: 630, source: dataAdapter, columnsheight: 50, columns: [ { text: 'Service Name', datafield: 'sName', width: 200, cellsrenderer: linkrenderer}, { text: 'Management IP', datafield: 'mgmtIP', width: 120 } ] }); }); </script>
The spinning “loading” keep spinning and not show up.
What am I doing wrong?Please help.
Thank you,
goldie
Hi goldie,
Change
datafields: [ { name: 'ID', type: 'string'}, { name: 'sName', type: 'string'}, { name: 'mgmtIP', type: 'string'} },
to
datafields: [ { name: 'ID', type: 'string'}, { name: 'sName', type: 'string'}, { name: 'mgmtIP', type: 'string'} ],
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comIvailo,
I’m sorry. I don’t seem to see the difference is what I need to make a change to. Can you bold or highlight the changes?
Thank you,
Goldie
Ivalio,
Never mind. I figure it out.
Here is my code if anyone might be looking for a similar solution:var dataAdapter = new $jsquery.jqx.dataAdapter(source); var linkrenderer = function (row, column, value) { var href = dataAdapter.records[row].ID; return '<a href="test.php?id='+href +'">'+value+'</a>'; }
-
AuthorPosts
You must be logged in to reply to this topic.