@{
    ViewData["Title"] = "Lista de SubCategorías";
}
<div class="container mt-4">
    <div class="row">
        <div class="col-8">
            <h2 class="text-primary">Lista de SubCategorías</h2>
        </div>
        <div class="col-4 text-right">
            <a asp-action="Create" class="btn btn-primary"><i class="fa-solid fa-plus"></i> Crear Nueva SubCategoría</a>
        </div>
    </div>
    <br />
    <br />
    <table id="tblSubCategorias" class="table table-striped table-bordered" style="width: 100%">
        <thead>
            <tr>
                <th class="text-center">Id</th>
                <th class="text-center">Categoría</th>
                <th class="text-center">Nombre</th>                
            </tr>
        </thead>
    </table>
</div>
@section Scripts {
    <script src="~/js/subCategoria.js"></script>
}
 
body {
  font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  color: #333;
  background-color: #fff;
}
 
var dataTable;
$(document).ready(function () {
    cargarDataTable();
});
function cargarDataTable() {
    dataTable = $("#tblSubCategorias").DataTable({
        "ajax": {
            "url": "/admin/subcategorias/GetAll",
            "type": "POST",
            "datatype": "json"
        },
        "processing": true,
        "serverSide": true,
        "pageLength": 10,
        "filter": true,
        "data": null,
        "responsive": true,
       
        "columns": [
            //{ "data": "id", "width": "5%" },
            //{ "data": "url", "width": "40%" },
            //{ "data": "descripcion", "width": "10%" },
            { "data": "id", "autoWidth": true },
            { "data": "categoria.nombre", "autoWidth": true },    
            { "data": "nombre", "autoWidth": true },            
           
        ],
        "language": {
            "decimal": "",
            "emptyTable": "No hay registros",
            "info": "Mostrando _START_ a _END_ de _TOTAL_ Entradas",
            "infoEmpty": "Mostrando 0 de 0 de un total de 0 Entradas",
            "infoFiltered": "(Filtrado de _MAX_ total entradas)",
            "infoPostFix": "",
            "thousands": ",",
            "lengthMenu": "Mostrar _MENU_ Entradas",
            "loadingRecords": "Cargando...",
            "processing": "Procesando...",
            "search": "Buscar:",
            "zeroRecords": "Sin resultados encontrados",           
            "paginate": {
                "first": "Primero",
                "last": "Ultimo",
                "next": "Siguiente",
                "previous": "Anterior"
            }
        },
        "width": "100%"
    });
}
function Delete(url) { /*ESTE METODO ES EL QUE SE LLAMA DESDE EL BOTON DE BORRAR DEL DATATABLE (QUE ESTÁ MÁS ARRIBA)*/
    swal({
        title: "¿Está seguro de borrar?",
        text: "¡Este contenido no se puede recuperar!",
        type: "warning",
        showCancelButton: true,
        cancelButtonText: "Cancelar",
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "Si, ¡borrar!",
        closeOnconfirm: true
    }, function () {
        $.ajax({
            type: 'DELETE', /*esto es la llamada al metodo que está en el controller*/
            url: url,
            success: function (data) {
                if (data.success) {
                    toastr.success(data.message);
                    dataTable.ajax.reload();
                }
                else {
                    toastr.error(data.message);
                }
            }
        });
        toastr.options = {
            //primeras opciones
            "closeButton": false, //boton cerrar
            "debug": false,
            "newestOnTop": false, //notificaciones mas nuevas van en la parte superior
            "progressBar": false, //barra de progreso hasta que se oculta la notificacion
            "preventDuplicates": false, //para prevenir mensajes duplicados
            "onclick": null,
            //Posición de la notificación
            //toast-bottom-left, toast-bottom-right, toast-bottom-left, toast-top-full-width, toast-top-center
            "positionClass": "toast-top-center",
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "5000",
            "extendedTimeOut": "1000",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut",
            "tapToDismiss": false,
        };
    });
}
Output 300px

This bin was created anonymously and its free preview time has expired. Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers