Initializing Datatable in a Modal after page loads with server side ajax post data

Initializing Datatable in a Modal after page loads with server side ajax post data

richb78ukrichb78uk Posts: 4Questions: 3Answers: 0

Hi,
Just wondering if there is something obvious I'm missing. I've used datatables all over with ajax data server side processing etc, and I've got a modal opening and then calling initialising code for the datatable, however when I try to access the form data for server side paging in my controller (asp.net core) like so

var draw = Request.Form["draw"].FirstOrDefault();
var start = Request.Form["start"].FirstOrDefault();
var length = Request.Form["length"].FirstOrDefault();

(I've used this when using datatables not loaded in a modal) it says it can't evaluate Form until all threads have run and bombs out with any error message.

I assume its because it loaded after the page load, anyone got any ideas to solve this?

Thanks
Richard

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @richb78uk ,

    I'm not familiar with asp.net, but could you set those variables in the table's initComplete function - that way the table will be initialised and the data loaded.

    Cheers,

    Colin

  • richb78ukrichb78uk Posts: 4Questions: 3Answers: 0

    For some reason just adding a parameter to the controller method fixes and form variables are present

This discussion has been closed.