table columns are result of db query

table columns are result of db query

jrsjrs Posts: 6Questions: 1Answers: 0
edited April 2015 in Free community support

I have a large table of assay values with many columns (samples), each column/sample has many rows representing genetic assay values. Since there are thousands of rows in the db table I am using server-side processing. This works well if I hardcode the columns/samples to display with DataTables.

My website has two functions: to select the samples to display (with a set of checkboxes) and to display with server-side processing the data table with the selected columns/samples.

The server-side example scripts all use a hardcoded $columns array of arrays. Since columns are the result of database query I cannot fix $columns in advance. I tried to POST this array to the server-side processing script but this didn't work.

My setup is the following:
first.html: displays the checkboxes to select the samples, submit to second.php
second.php: shows checkboxes, checked for compatible samples (there is a hierarchy of samples); checked boxes can be unchecked
third.php: searches database for selected samples and should display with server-side datatables plugin.

It is not clear to me how to combine the selected samples list with server-side processing.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,020Questions: 1Answers: 10,555 Site admin
    Answer ✓

    The server-side example scripts all use a hardcoded $columns array of arrays. Since columns are the result of database query I cannot fix $columns in advance

    Are you using the SSP class? If so, there is no reason why $columns need be fixed, you can creating it dynamically using custom PHP if that is what you require.

    The key thing to note about columns in DataTables is that they must be defined when the DataTable is initialised and the column definition cannot be loaded by DataTables' own Ajax call. So if you wanted the columns to be defined by the server-side (I'm not sure if you do? But I thought I'd point this out anyway) that would need to be done in a custom Ajax call.

    Regards,
    Allan

This discussion has been closed.