Redirect to url when push edit button
Redirect to url when push edit button
ManuelBR
Posts: 1Questions: 1Answers: 0
Hi, I have started using DataTables. I have designed a system with Visual Studio 2017 MVC.
I have created a simple VIEW to list all users.
My problem is that I don't know how to redirect to my controller when the edit button is pushed.
Could you help me?
Thank's
Code View:
@{
ViewBag.Title = "Index";
}
@using Pegasus.Griffin.Cms.Resources;
@*<a class="editor_create">Create new record</a>*@
<div class="col-lg-12 content">
<div class="col-lg-12 GlobalTitleContent">
<div class="col-lg-6 padding0">
<span class="icon-ntpk-usuario iconsTitleContent pull-left"></span> <div class="titleContent">@ResourcesViews.mnuUsers</div>
</div>
<div class="col-lg-6 pull-right">
<div class="pull-right cursorPointer">
<a href="@Url.Action("Create", "Users")">
<span class="icon-ntpk-nuevo-usuario iconsTitleContent pull-left"></span> <div class="titleAdd pull-left text">@ResourcesViews.lblNewUser</div>
</a>
</div>
</div>
</div>
<div class="col-lg-12 contentGrids">
<table id="tableDetails" class="table.dataTable display" cellspacing="0" width="100%">
<thead>
<tr>
<th>userId</th>
<th>Nombre</th>
<th>Apellidos</th>
<th>Perfil</th>
<th>Login</th>
<th>Edit / Delete</th>
</tr>
</thead>
<tfoot>
<tr>
<th>userId</th>
<th>Nombre</th>
<th>Apellidos</th>
<th>Perfil</th>
<th>Login</th>
<th>Edit / Delete</th>
</tr>
</tfoot>
</table>
</div>
</div>
@section scripts{
<script type="text/javascript">
$(document).ready(function () {
// Edit record
$('#tableDetails').on('click', 'a.editor_edit', function (e) {
var id = $(this).closest('tr').find('td').eq(0).text();
/////////////////////////////////////////////
// How to redirect to URL -> /Users/Edit?idEdit=id //
/////////////////////////////////////////////
}),
$('#tableDetails').DataTable(
{
"processing": true,
"serverSide": true,
"lengthChange": true,
"filter": true,
"info": true,
"paging": true,
"paginationType": "full_numbers",
"ajax": "/Users/LoadDataTable",
"idSrc": "idUser",
language:
{
search: "@ResourcesViews.gridNameFilter",
lengthMenu: "_MENU_ " + "@ResourcesViews.gridItemsPerPage",
info: "@ResourcesViews.gridViewPage" + " _PAGE_ de _PAGES_",
infoEmpty: "",
infoFiltered: "",
zeroRecords: "@ResourcesViews.gridZeroResultsGrids",
paginate:
{
next: '>',
last: '',
first: '',
previous: '<'
}
},
"columnDefs": [
{ "orderable": true, "targets": [0] },
{ "orderable": true, "targets": [1] },
{ "orderable": true, "targets": [2] },
{ "orderable": true, "targets": [3] },
{ "orderable": false, "targets": [4] }
],
columns: [
{ "data": "userId" },
{ "data": "name" },
{ "data": "surname" },
{ "data": "profileName" },
{ "data": "login" },
{
data: null,
className: "center",
defaultContent: '<a href="" class="editor_edit">Edit</a></a>'
}
]
});
});
</script>
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @ManuelBR ,
Is this using Editor? Or do you jsut want to do a standard redirect? If standard, then it's
Cheers,
Colin