DataTables Editor: Pull field data on demand.

DataTables Editor: Pull field data on demand.

washuit-iammwashuit-iamm Posts: 133Questions: 55Answers: 2

Sorry if this has been asked before but my google fu did not help me today.

My DataTable has 100 columns but I mark 95 as visible: false this way my edit has all the data to do its job. But 50 rows from my server is 400kb (I am not yet using compression).

It would be nice to only ask for 4 columns and on initEdit fill up the data needed by DT to do the job. Are there any examples of doing this? I assume I will modify the $.fn.dataTable.Buttons edit button, and in the action I can get the selected rows and go ask for more columns and pass that to editor.edit()?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Answer ✓

    Its not a built in feature (although I have thought about it and continue to consider it!), but it can readily be done with the initEdit event. Listen for that event and have your function send an Ajax request to the server to get the data for the extra fields (perhaps a different URL or with a query string parameter to distinguish it), then use val() to set the values of the fields. You might want to show a little "processing" icon while that extra data is being loaded - just so the user can see that something is still happening.

    Allan

This discussion has been closed.