54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
var tabla;
|
|
|
|
//funcion que se ejecuta al inicio
|
|
function init(){
|
|
mostrarform(false);
|
|
listar();
|
|
|
|
}
|
|
|
|
|
|
//funcion mostrar formulario
|
|
function mostrarform(flag){
|
|
if(flag){
|
|
$("#listadoregistros").hide();
|
|
$("#formularioregistros").show();
|
|
$("#btnGuardar").prop("disabled",false);
|
|
$("#btnagregar").hide();
|
|
}else{
|
|
$("#listadoregistros").show();
|
|
$("#formularioregistros").hide();
|
|
$("#btnagregar").hide();
|
|
}
|
|
}
|
|
|
|
|
|
//funcion listar
|
|
function listar(){
|
|
tabla=$('#tbllistado').dataTable({
|
|
"aProcessing": true,//activamos el procedimiento del datatable
|
|
"aServerSide": true,//paginacion y filrado realizados por el server
|
|
dom: 'Bfrtip',//definimos los elementos del control de la tabla
|
|
buttons: [
|
|
'copyHtml5',
|
|
'excelHtml5',
|
|
'csvHtml5',
|
|
'pdf'
|
|
],
|
|
"ajax":
|
|
{
|
|
url:'../ajax/permiso.php?op=listar',
|
|
type: "get",
|
|
dataType : "json",
|
|
error:function(e){
|
|
console.log(e.responseText);
|
|
}
|
|
},
|
|
"bDestroy":true,
|
|
"iDisplayLength":10,//paginacion
|
|
"order":[[0,"desc"]]//ordenar (columna, orden)
|
|
}).DataTable();
|
|
}
|
|
|
|
|
|
init(); |