How can I manipulate Table properties dynamically?
How can I manipulate Table properties dynamically?
Hi Guys, I have a lock and I hope you can help me. Basically I have an instace of DataTable with Ajax source set, and also I use SignalR to manipulate table data loaded via Ajax. The problem is when I want to redraw the table after manipulating the table data is triggered Ajax call. I've been override the ajax method
//SignalR
hub.client.updateData = function (newData) {
//self.TableData manipulation
//lock the server side call
self.stopTableAjax = true;
self.Table.ajax.reload();
}
//table settings
{
...,
serverSide: true,
processing: true,
ajax:function (data, callback, settings) {
if (self.stopTableAjax) {
callback(self.TableData);
self.stopTableAjax = false;
} else {
$.post("/EndPoint", data)
.done(function (response) {
self.TableData = response;
callback(self.TableData);
});
}
}
}
but the problem is that the serverSide and processing properties leaving the table locked after
calling
if (self.stopTableAjax) {
callback(self.TableData);
self.stopTableAjax = false;
}
How can I manipulate properties dynamically?
Thanks
This question has an accepted answers - jump to answer
Answers
It looks like
self.TableData
is the response from the last Ajax request - is that correct? If so, you'd need to modify thedraw
parameter for the next draw since it is unique for every draw.should probably do it.
Allan
Hi Allan,
Yes, that is correct, I keep the last ajax request in
self.TableData
as this is valid object for the callback, and hereI manipulating just the data property .I've fixed, my code, using your suggestion and it work like a boss right now.
Thank you so much.