How to add info in the badge to the row next to another info

How to add info in the badge to the row next to another info

Katia_LTKatia_LT Posts: 13Questions: 6Answers: 0

https://live.datatables.net/xugehuxi/1/edit

I want that where is the name column next to it would be start date displayed in the badge.
How to achieve it?

Thanks in advance.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,451Questions: 1Answers: 10,465 Site admin
    Answer ✓

    https://live.datatables.net/xugehuxi/2/edit

    The row parameter gives you the data object for the whole row. In this case, that is an array since it is being read from the HTML.

    Allan

  • Katia_LTKatia_LT Posts: 13Questions: 6Answers: 0

    Great solution, thank you.
    But I am using ajax call from the SharePoint list.

    I get this data from the call:

    {
        "d": {
            "results": [
            {
            "__metadata": {
            "id": "1e76fb27-4eba-4dbe-8e67-fec5c3218eee",
            "uri": "https://website/_api/Web/Lists(guid'20991fd5-4380-4a14-830d-1e243f41cebw')/Items(1)",
            "etag": "\"5\"",
            "type": "SP.Data.ListListItem"
        },
        "Id": 1,
        "Title": "Name",
        "Modified": "2023-10-26T06:57:02Z"
                },
        {
            "__metadata": {
            "id": "1e76fb27-4eba-4dbe-8e67-fec5c3218eee",
            "uri": "https://website/_api/Web/Lists(guid'20991fd5-4380-4a14-830d-1e243f41cebw')/Items(1)",
            "etag": "\"5\"",
            "type": "SP.Data.ListListItem"
        },
        "Id": 2,
        "Title": "Name2",
        "Modified": "2023-10-26T06:57:02Z"
        }
    ]
        }
    }
    

    I want to have a badge with modified date next to the tilte.

    How to achieve the same in this case?

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945
    Answer ✓

    Use object notation to access the specific row object, something like this:

          render: function (data, type, row) {
            return data + '<span class="badge rounded-pill">' + row.Modified + "</span>";
          },
    

    Kevin

Sign In or Register to comment.