RowCallback / ReRender from Modal Close

RowCallback / ReRender from Modal Close

browe68browe68 Posts: 2Questions: 1Answers: 0

I have a bootstrap modal. Once it closes I want to call the "rowCallback" function where I have a lot of logic to alter the html displayed in various cells (dependent upon data).

I could "draw" the whole table, but my data is in a server and takes several seconds to redraw. So, I need a faster way.

I am making a call to an external function in the "rowCallback", so that it is accessible to the modal close event. I am having an issue with the "row" variable... how do I pass this in.

"rowCallback": function (row, data, iDisplayIndex) { 
    //  This works great when called on the initial draw.
        MyExternalFunction(row, data, displayindex)
}


ModalClose
{
        // This works other than first variable.
       var displayindex = Saved in local variable.
       var data = table.row(displayindex).data();

       // The 2 object reference below are correct and accurately get the object, however when passed in to "MyExternalFunction" , DataTable does not reRender.

       Doesn't work -->    var row = $('#Datatable').find('tr').eq(displayindex);  
       Doesn't work -->    var row = table.row(displayindex);  

        MyExternalFunction(row, data, displayindex)
}

MyExternalFunction(row, data, displayindex)
{

  I have a row, object passed in, but doesn't work.
  This works perfectly, other than getting "row" variable from external function.

}

Is there a different way to reRender just the current row so that my cell display the html derived from logic?

Answers

  • kthorngrenkthorngren Posts: 21,350Questions: 26Answers: 4,955

    I'm not sure I totally understand your description. Your code snippets aren't enough to understand what your code is doing.

    You probably know all this... The rowCallback only runs for the rows displayed on the page. You can use draw() to have rowCallback run. If you pass false as a draw() parameter the table will stay on the current page, for example table.draw(false);.

    Using draw() does not load the whole table again. If you are using server side processing it will fetch the current page's data. Otherwise the data in the client will be redrawn without fetching anything. Maybe in your ModalClose function you can simply use table.draw(false);.

    If you continue to have difficulties with your ModalClose function then we will need to see a link to your page or a test case to help diagnose.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

This discussion has been closed.