[jquery datatable] .ajax.reload() non riconosciuto

mercoledì 21 gennaio 2015 - 13.27

svipla Profilo | Senior Member

Ciao a tutti
Ho questo codice che mi crea un datatable in un file esterno .js:

var TableManaged = function () {

return {

//main function to initiate the module
init: function () {

if (!jQuery().dataTable) {
return;
}

// begin table
oTable = $('#dtElenco').dataTable({
"oLanguage": {
"sUrl": "/Metronic/plugins/data-tables/language/it-IT.txt"
},
"aoColumns": [
{ "bSortable": false },
{ "bSortable": false },
null,
null,
null,
null,
null,
{ "bSortable": false }
],
"aaSorting": [[3, "asc"]],
"aLengthMenu": [
[5, 15, 20, -1],
[5, 15, 20, "Tutti"] // change per page values here
],
// set the initial value
"iDisplayLength": 5,
"sPaginationType": "bootstrap",
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [0] },
{ "bSearchable": false, "aTargets": [0] }
]
});

jQuery('#dtElenco .group-checkable').change(function () {
var set = jQuery(this).attr("data-set");
var checked = jQuery(this).is(":checked");
jQuery(set).each(function () {
if (checked) {
$(this).attr("checked", true);
$(this).parents('tr').addClass("active");
} else {
$(this).attr("checked", false);
$(this).parents('tr').removeClass("active");
}
});
jQuery.uniform.update(set);
});

jQuery('#dtElenco').on('change', 'tbody tr .checkboxes', function () {
$(this).parents('tr').toggleClass("active");
});

jQuery('#dtElenco_wrapper .dataTables_filter input').addClass("form-control input-medium input-inline"); // modify table search input
jQuery('#dtElenco_wrapper .dataTables_length select').addClass("form-control input-xsmall input-inline"); // modify table per page dropdown
//jQuery('#dtElenco_wrapper .dataTables_length select').select2(); // initialize select2 dropdown


// ChangeStatus
$('#dtElenco').on('click', '[id*="btnStatus"]', function () {
var btnStatus = $(this);
var id = btnStatus.attr('data-id');

if ($.trim(id) != '') {
$.ajax({
url: '/Handler/ajaxOperation.ashx',
data: { type: 'changeStatusStrutturaContatto', id: id },
cache: false,
async: false,
dataType: 'json',
type: 'POST',
error: function (request, error) {
$('.alert-danger', $('.form-data')).show();
$('.alert-danger', $('.form-data')).find('span').html('Impossibile completare l\'operazione');
},
success: function (response) {
if (response.msg_error != '') {
$('.alert-danger', $('.form-data')).show();
$('.alert-danger', $('.form-data')).find('span').html(response.msg_error);
}
else {
oTable.api().ajax.reload();
//location.reload();
}
}
});
}
});
// fine ChangeStatus
}

};

}();

Quando eseguo oTable.api().ajax.reload(); (ho anche provato con oTable.ajax.reload(); e $('#dtElenco').dataTable().api().ajax.reload();) non fa nulla è ricevo questo errore:
TypeError: oTable.ajax is undefined

oTable.ajax.reload();

Prima utilizzavo oTable.fnReloadAjax(); su un altro template e non avevo problemi, ora utilizzo metronic e ho problemi.
da cosa può dipendere?
Grazie mille
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5