Multiple links in one cell

Multiple links in one cell

floodyfloody Posts: 4Questions: 2Answers: 0

I have a list that is returning items and each item has multiple attachments which I can display e.g.filename and urls in the same row cell. Is it possible to render each url as a hyperlink in the same cell?

Answers

  • Rawland_HustleRawland_Hustle Posts: 94Questions: 16Answers: 0

    Sure. What does your data look like?

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    with the render:function() {} but as Rawland_Hustle says, we need to see your data for one row to know how to help you

  • floodyfloody Posts: 4Questions: 2Answers: 0
    edited May 2017

    Hi all,

    Thanks! Here is the structure of a portion of the data (one item).


    "d":{ "results":[ { "AttachmentFiles":{ "results":[ { "FileName":"19-04-2017 09-02-36.pdf", "ServerRelativeUrl":"Lists/D/Attachments/7/19-04-2017 09-02-36.pdf" }, { "FileName":"19-04-2017 09-04-26.pdf", "ServerRelativeUrl":"/Lists/D/Attachments/7/19-04-2017 09-04-26.pdf" } ] }, "Title":"Test", "Modified":"2017-05-10T09:51:48Z", "Created":"2017-05-09T07:23:10Z", },

    and the script part.


    List().done(function (data) { console.log(data.d.results); for (var i = 0; i < data.d.results.length; i++) { var item = data.d.results[i]; var title = item.Title; var attachmentUrl = []; for (var x in item.AttachmentFiles.results) attachmentUrl.push(item.AttachmentFiles.results[x].ServerRelativeUrl); //var fileName = attachmentUrl.FileName; data.d.results[i].attachmentUrl = attachmentUrl.join("<br>"); } var table = $('#simlist').dataTable({ "ordering": false, "searching": false, "info": false, "bDestroy": true, "bProcessing": true, "paging": false, "aaData": data.d.results, "aoColumns": [{ "mData": "Title" }, { "mData": "Amount_x0020_of_x0020_SIM_x0020_" }, { "mData": "SIM_x0020_Card_x0020_Status" }, { "mData": "Phone_x0020_Numbers" }, { "mData": "SIM_x0020_Card_x0020_Number" }, { "mData": "attachmentUrl", }] });
  • floodyfloody Posts: 4Questions: 2Answers: 0

    So what I did (with the help of a friend) is amend the following code which wrapped the results in href tag. So I didnt use the render function. under AttachmentUrl.

    attachmentUrl.push("<a href='https://tenant.sharepoint.com" + item.AttachmentFiles.results[x].ServerRelativeUrl + "' target='_blank'>" + item.AttachmentFiles.results[x].FileName + "</a>");

This discussion has been closed.