HOW TO: show/hide details where details are not in the datatable itself.

HOW TO: show/hide details where details are not in the datatable itself.

mediabros.mediabros. Posts: 2Questions: 0Answers: 0
edited August 2010 in General
The Case:

I have some records in a datatable which i generated by a php loop. i am using the show/hide details function.

The data that is in the detailbox (visible when a user clicked on the plus icon) is still the data from the default example.

[code] var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += 'Rendering engine:'+aData[1]+' '+aData[4]+'';
sOut += 'Link to source:Could provide a link here';
sOut += 'Extra info:And any further details here (images etc)';
sOut += '';
[/code]

It is getting data from a table cell g.e. '+aData[4]+' and some of it is hardcoded.

What i want is to user is a php variable instead of the data that is already in a datacell.

Is it possible with php? how should i approach this?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It's certainly possible - but remember that this is being done on the client-side, and not the server-side. So your PHP variable needs to be made available to the client-side somehow - in my example I put the information into a hidden column. You can put it anywhere you want (JS variables whatever), or use an XHR to load it dynamically.

    Allan
  • mediabros.mediabros. Posts: 2Questions: 0Answers: 0
    Hi Allan,

    Thanks for the answer, i will give the hidden columns a shot. I assume you hide the columns with css is that correct?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    No - with the DataTables method for hiding columns: http://datatables.net/usage/columns#bVisible

    Allan
  • pktmpktm Posts: 27Questions: 0Answers: 0
    I'm using the primary key of the records in a hidden column, using it to retirve the full record via ajax calls when needed. Works fine :)
This discussion has been closed.