I have a datatable and the last column are two buttons. Im implementing responsive datatables but I need that the last column (Column "Opciones") is not hidden and always show regardless the others colums.
If you need more information just tell me.
HTML (ASP.NET View)
@model PagedList.IPagedList<VinculoSC.ReservaDeCabanasWeb.Models.Reserva>
@using PagedList.Mvc;
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout2.cshtml";
}
<div id="content">
<div>
<div class="row">
<div id="divAlertReserva" role="alert"></div>
</div>
</div>
<table class="table" id="listaSolicitudes" width="100%">
<thead>
<tr>
<th>
Cabaña
</th>
<th>
Empresa
</th>
<th>
Cédula
</th>
<th>
Nombres
</th>
<th>
Apellidos
</th>
<th>
Email
</th>
<th>
Fecha inicial
</th>
<th>
Fecha final
</th>
<th>
Opciones
</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div id="openModal" class="modalDialog">
<div>
<a href="#close" title="Close" class="close" onclick="CancelOperation()">X</a>
<h2>Por favor anexe una descripción al correo</h2>
<textarea id="txtDescription" class="form-control" rows="4"></textarea>
<input type="text" id="iptValue" name="iptValue" value="" style="display:none;" />
<input type="text" id="iptID" name="iptID" value="" style="display:none;" />
<a class='btn btn-default' style="margin-top:7px;" onclick="SendInformation()">Enviar</a>
</div>
</div>
<div id="openConfirmation" class="modalDialog" role="alert">
<div id="confirmation">
<a href="#close" title="Close" class="close" onclick="CancelOperation()">X</a>
<h4>¿Esta seguro que desea rechazar la solicitud?</h4>
<a class='btn btn-default' style="margin-top:7px;" onclick="location.href = '#openModal';">Si</a>
<a href="#close" class='btn btn-default' style="margin-top:7px;" onclick="CancelOperation()">No</a>
</div>
</div>
<script>
//This is by the auto-resize and modal windows issue
function OpenPolicies() {
}
</script>
Javascript
$(document).ready(function () {
var table = $('#listaSolicitudes').DataTable({
"bServerSide": true,
"sAjaxSource": "ListaSolicitudes/AjaxHandler",
"bProcessing": true,
"aoColumns": [
{ "sName": "Cabana" },
{ "sName": "Empresa" },
{ "sName": "Cedula" },
{ "sName": "Nombres" },
{ "sName": "Apellidos" },
{ "sName": "Email" },
{ "sName": "FechaDesde" },
{ "sName": "FechaHasta" },
{ "sName": "Opciones" }
],
"columnDefs": [{
"targets": -1,
"data": null,
"defaultContent": "<span>" +
"<div>" +
"<a id='aprobar' class='btn btn-default'>Aprobar</a>" +
"</div>" +
"<div style='margin-top:5px;'>" +
"<a id='rechazar' class='btn btn-default'>Rechazar</a>" +
"</div>" +
"</span>" +
"<span class='loading'>" +
"<img src='" + decodeURIComponent(sessionStorage.spHostUrl) + "/pru-reservaCabanas/_layouts/images/gears_anv4.gif' alt='Cargando...'/>" +
"</span>"
}],
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.6/i18n/Spanish.json"
},
"fnDrawCallback": function (oSettings) {
$(".loading").hide();
$(".loading").css("margin", "0 38%");
Capatech.Part.adjustSize();
},
responsive: {
details: {
type: 'inline'
}
}
});
});
FixedColumns allows columns to be fixed from both the left and the right hand sides of the table. Fixing right hand-side columns is done by using the fixedColumns. right initialisation parameter, which works just the same as fixedColumns. left does for the left side of the table.
FixedColumns provides the option to freeze one or more columns to the left or right of a horizontally scrolling DataTable. This allows information in the fixed columns to remain visible even when scrolling through the data set. This can be particularly useful if you wish to show a large number of columns.
The autoWidth option is used to specify whether the automatic calculation of the column width in the DataTable is enabled or not. This calculation takes a little time and may be disabled when the column widths are explicitly passed using the columns.
Responsive is an extension for DataTables that resolves that problem by optimising the table's layout for different screen sizes through the dynamic insertion and removal of columns from the table.
Only add the class .all to the table header column that you want to persist.
<th class="all">
Opciones
</th>
For more info see: https://www.datatables.net/extensions/responsive/examples/display-control/classes.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With