I could not add EDIT button on my application (seems to be broken - foreach)

I could not add EDIT button on my application (seems to be broken - foreach)

DataTableGuy10DataTableGuy10 Posts: 6Questions: 2Answers: 0

I decided to use a DATATABLE but i could not make it work on my previous model, everything works just fine but the EDIT button is not even working. Dont want to use AJAX or something like that, just the information retrieved in my FOREACH

This is my code (do NOTE that i used a foreach):
@model IEnumerable<WebApplication.Models.Approval>

@{
ViewData["Title"] = "Approvals";
}

Approvals

@foreach (var item in Model) { }
@Html.DisplayNameFor(model => model.CODE) @Html.DisplayNameFor(model => model.EMAIL) @Html.DisplayNameFor(model => model.FIRSTNAME) @Html.DisplayNameFor(model => model.LASTNAME)
@Html.DisplayFor(modelItem => item.CODE) @Html.DisplayFor(modelItem => item.EMAIL) @Html.DisplayFor(modelItem => item.FIRSTNAME) @Html.DisplayFor(modelItem => item.LASTNAME) @Html.ActionLink("EDIT", "Edit", new { id = item.code })

How should i create my JS script in order to make it work?Can help me?
I was thinking about something like this:

$(document).ready(function () { $('#myDataTable').dataTable({ aoColumns: [ null, // first column (CODE) null, // second column (EMAIL) null, // third (FIRSTNAME) null, // fourth (LASTNAME) { // fifth column (Edit link) "sName": "EDIT", "bSearchable": false, "bSortable": false, "fnRender": function (oObj) { // oObj.aData[0] returns the CODE return "Edit"; } } ] }); });

Answers

This discussion has been closed.