Custom Column and 'inline' PHP

Custom Column and 'inline' PHP

CraiggJCraiggJ Posts: 2Questions: 0Answers: 0
edited July 2012 in DataTables 1.9
Hi there!

I'll try and keep it brief. I've recently come across DataTables to portray my data from my database, my data source is server-side processing.

My current table (which isn't DataTables) has an additional column which is used for static images which are hyperlinked to a relevant page. I know how to do this when using my current table I just add an addition [code]Options[/code], when I do this within DataTables and run the script none of my data is loaded, I understand the reason behind that (because of the Array to fetch the data).

I've read in the comments within the server processing file (examples/server_side/scripts/server_processing.php) that you need to leave a 'space', which I've tried. But doesn't work, nothing loads.

So my question is how do I add this additional column with my static images and accompanying code?

The second half of my question is, the hyperlink of these images are to a relevant page - such a delete or edit page, part of the hyperlink has some PHP echoed. (example: edit.php?record=$id) I'm not sure how to go about it in DataTables due to the array, I could probably work it out but I'm clueless as to where the code goes.

Any help is very much appreciated. Thank you.

Replies

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin
    > So my question is how do I add this additional column with my static images and accompanying code?

    Are you set on using arrays as your data source, or could you use objects? If using objects you could use this method: http://datatables.net/blog/Extended_data_source_options_with_DataTables + sDefaultContent for your static images.

    In fairness you can actually use that method with arrays as well, but the indexes being shifted can get a little confusing...!

    Second half question - look at using fnRender .

    Allan
  • CraiggJCraiggJ Posts: 2Questions: 0Answers: 0
    Thanks for your reply, Allan.

    Whilst I understand some of your reply, I can't seem to put it in to practice. Upon searching the forums some more I come across this thread: http://datatables.net/forums/discussion/1581/problem-to-adding-a-custom-column/p1

    Which seems to be part of what I'm looking for, however it seems that this is for an older version of DataTables.

    Is: [code]$sOutput .= '"column value",';[/code] still working/allowed to be used?

    Because I've managed to add the additional column heading called 'options'. I figure for each [code]$sOutPut[/code] I add would be an additional column?

    So theoretically I could do the following:

    [code]$sOutput .= [/code]
This discussion has been closed.