Combining a URL with ID from a column?
Combining a URL with ID from a column?

Hi again guys!
I am trying to append an EDIT url to each of my entries and I figured my best option would be to do something like..
goo.gastme.com/edititem.aspx?ID=[RowID]
I want to replace the RowID with whatever is in the RowID column so that each item will have an EDIT button next to it. Is that something you guys can help me with?
So far this is all i've got but its giving me the wrong link
"columnDefs": [ {
"targets": 9,
"data": "download_link",
"render": function ( data, type, full, meta ) {
return '<a href="'+data+'">Here</a>'; }
}
],
send me to link "http://Rob.Shareoint.com/SitePages/[object%20Object]"
which is where I have the datatable but isnt where the EditItem page is located..
<script language="javascript" type="text/javascript" src="../SiteAssets/js/jquery-1.11.1.min.js"></script>
<script language="javascript" type="text/javascript" src="../SiteAssets/js/jquery.dataTables.min.js"></script>
<script language="javascript" type="text/javascript" src="../SiteAssets/js/dataTables.tableTools.min.js"></script>
<link rel="stylesheet" type="text/css" href="../SiteAssets/js/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="../SiteAssets/js/dataTables.tableTools.min.css">
<table width="100%" cellspacing="0" class="display" id="state">
<thead>
<th>Site Common Name</th>
<th>Site CLLI(8)</th>
<th>GLC #</th>
<th>City</th>
<th>State</th>
<th>Controller Make & Model</th>
<th>Controller Location in Bldg</th>
<th>Panel Tag</th>
<th>Remarks</th>
<th>EditButton(WIP)</th>
<th>Controller CLLI</th>
<th>VMN Switch Designation</th>
<th>VMN Switch Location</th>
<th>VMN Switch Model</th>
<th>RR Location</th>
<th>Mounting Position(MP)</th>
<th>Assigned Port</th>
<th>IP Address</th>
<th>Gateway</th>
<th>Subnet Mask</th>
<th>VLAN</th>
<th>IPPOC Assigned</th>
<th>DNS Updated (CLLI Code)</th>
<th>BAS dB Updated</th>
<th>Internal Remarks</th>
<th>ID</th>
</thead>
</table>
<br>
<br>
<br>
<script language="javascript">
$(document).ready(
function(){
var call = $.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('BAS/BMS Assignments')/items?$top=5000",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function (data,textStatus, jqXHR){
$('#state').dataTable({
"pageLength": 8,
"columns": [
{"width": "5%"},
null,
{
"min-width": "50%"}
],
"columnDefs": [ {
"targets": 9,
"data": "download_link",
"render": function ( data, type, full, meta ) {
return '<a href="'+data+'">Here</a>'; }
}
],
"scrollX": 200,
"ordering": true,
"info": false,
"bDestroy": true,
"bProcessing": true,
"aaData": data.d.results,
"aoColumns": [
{ "mData": "j5vx" },
{ "mData": "Title" },
{ "mData": "GLC" },
{ "mData": "City" },
{ "mData": "State" },
{ "mData": "Device_x0020_Model_x0020_Number" },
{ "mData": "Controller_x0020_Location_x0020_" },
{ "mData": "Panel_x0020_Tag" },
{ "mData": "Remarks" },
{ "mData": null},
{ "mData": "Controller_x0020_CLLI"},
{ "mData": "Switch_x0020_Designation" },
{ "mData": "VMN_x0020_Switch_x0020_Location" },
{ "mData": "Switch_x0020_Model" },
{ "mData": "RR_x0020_Location"},
{ "mData": "xh4i" },
{ "mData": "Assigned_x0020_Port" },
{ "mData": "IP_x0020_Address" },
{ "mData": "Gateway" },
{ "mData": "Subnet_x0020_Mask" },
{ "mData": "x21p" },
{ "mData": "t78z" },
{ "mData": "lqau" },
{ "mData": "BAS_x0020_dB_x0020_Updated" },
{ "mData": "Remarks" },
{ "mData": "RowID" },
],
Answers
Try
I appreciate the promptness.
this is returning http://URL/EditForm.aspx?ID=undefined
this as show is not right
return '<a href="'URL\formitem.aspx?ID=+data.RowID+'">Here</a>';
try
I made the change but I am stilling seeing undefined
The issue seems to be related to my columnDef
Figured it out.
Here is how I achieved this:
I wanted to show the DisplayedColumn in the datatable column, but have the ID sent with the request when clicked. I also did not want to display the ID column.
This was, sadly, very hard to find an answer to, I hope it helps someone.
All I wanted was the current data wrapped into a URL. This worked for me.