fnDeleteRow driving me crazy!

fnDeleteRow driving me crazy!

awvidmerawvidmer Posts: 8Questions: 0Answers: 0
edited June 2012 in DataTables 1.9
Hi, Allan:

I'm using fullCalendar along with dataTables 1.9.1, and I'm trying to get a row to delete in a dataTable when I click an event in fullCalendar. I've been successful in identifying the proper row in the dataTable (both as an index or as a tr element), the id logged is correct, and a row deletes, but it's a completely random one. Could you have a quick peek at this code and see if you spot something? Would the row grouping extension have any effect? (Not using here, but elsewhere). Many thanks! --Tony


$(document).ready(function() {
var oTable = $('#dataTables3dadmin').dataTable();

// page is now ready, initialize the calendar...

$('#full_calendar4').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultView: 'month',
height: 600,
eventSources: [{
url: '/pevents',
color: '#83AEFF',
textColor: 'black',
className: 'tevents',
ignoreTimezone: true
}
],


eventRender: function(event, element) {
element.find('.fc-event-title').append(": " + "" + event.description + "");
},
eventClick: function(event) {

//setting up oTable var here!

var pevt = event.id;
var rid = ($('#evnt_'+ pevt));
console.log(rid);

if (confirm("Remove Event from Poketinerary?")) {
$.ajax({
type:'DELETE',
url: '/pevents/1',
data:'event_id='+event.id,
});
$(this).fadeOut();
//here's the delete call!
oTable.fnDeleteRow(rid);
return false;
} else {
return false;
}
}

})

});

Replies

  • awvidmerawvidmer Posts: 8Questions: 0Answers: 0
    Figured it out. The dataTable cannot be sorted in the initialization parameters! For some reason, the original, presorted row number is saved somehow. Solution was to presort data prior to initialization. Maybe that makes sense, but it stumped me for quite a while....
  • awvidmerawvidmer Posts: 8Questions: 0Answers: 0
    Actually, any AJAX sort after initialization causes the delete to fail, of course. I guess I'd have to call back to the calendar to reset the values? Hmmm....
This discussion has been closed.