How can I manipulate Table properties dynamically?

How can I manipulate Table properties dynamically?

dumitru.chirutac@gmail.comdumitru.chirutac@gmail.com Posts: 2Questions: 1Answers: 0

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

  • allanallan Posts: 61,950Questions: 1Answers: 10,158 Site admin
    Answer ✓

    It looks like self.TableData is the response from the last Ajax request - is that correct? If so, you'd need to modify the draw parameter for the next draw since it is unique for every draw.

                self.TableData.draw = data.draw;
                callback(self.TableData);
                self.stopTableAjax = false;  
    

    should probably do it.

    Allan

  • dumitru.chirutac@gmail.comdumitru.chirutac@gmail.com Posts: 2Questions: 1Answers: 0

    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.

This discussion has been closed.