Link to the fnAddData while populating History Datatable in the ajax success

Link to the fnAddData while populating History Datatable in the ajax success

SweetAnonymousSweetAnonymous Posts: 18Questions: 1Answers: 0
edited August 2019 in Free community support
function GetLoggedInUserLast10History() {
    $('#UserCreatedHistory').modal('show');
    $.ajax({
        url: '/Home/GetLoggedInUserLast10History',

        contentType: "application/json; charset=utf-8",
        type: "POST",
        async: false,
        success: function (data) {
            if ((data != null) || (data != "")) {
                myJsonData = data;
                populateHistoryDataTable(myJsonData);
            }
        },
        error: function (response) {
            $('#UserCreatedHistory').modal('hide');
            toastr.warning("Error in GetLoggedInUserLast10History");
        },
        failure: function (response) {
            $('#UserCreatedHistory').modal('hide');
            toastr.warning("Failure in GetLoggedInUserLast10History");
        }
    });
}


function populateHistoryDataTable(data) {
    // clear the table before populating it with more data
    $("#tblIndexUserCreatedHistory").DataTable().clear();
    var length = Object.keys(data).length;
    for (var i = 0; i < length; i++) {
        var userData = data[i];
        // You could also use an ajax property on the data table initialization
        $('#tblIndexUserCreatedHistory').dataTable().fnAddData([
           userData.UserId,
          userData.DisplayName,
          userData.EventName,
          userData.CreatedDateString
        ]);
    }
}

This is working fine. How do i give link to the User Id field to navigate to a different page in PopulateHistoryDataTable?

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This discussion has been closed.