HTML Columns

HTML Columns

Manny89Manny89 Posts: 5Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
I've managed to get DataTables to do exactly what I want it to do with regards to loading data from a MySQL database using PHP. This works perfectly fine, but I need to add an extra column to the end of my table which is written in PHP.

My table is being populated with data from my JSON file, but I get the following message because the end column is empty:
[code]DataTables warning (table id = 'datatables'): Requested unknown parameter '5' from the data source for row 0[/code]

My question here is, can I add the content of the extra column manually by editing my PHP file?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Not sure sure I understand I'm afraid - where is the data for the extra column coming from, the JSON I guess, but why is there an extra column with no data in it - what should go in it? Perhaps sDefaultContent would help?

    Allan
  • Manny89Manny89 Posts: 5Questions: 0Answers: 0
    I apologise. I'll try to explain it a little better.

    I have created a table with five columns, but I only want to pull information from a JSON file for the first four of these. In the fifth (end) column, I want to code something in PHP or HTML that will fill the content of that empty column. For example, they could be links to an edit page that are dynamically created in PHP.

    Here is my code.

    [code]



    ID
    Date
    Title
    Keywords
    Actions





    [/code]

    The five columns have been defined in the thead and the content is loaded through sAjaxSource, which is referencing a JSON file containing four fields per child element. These then fill the first four columns of each row inside tbody.

    My question is how can I add content for the empty fifth column through HTML or PHP and not the JSON file.
  • david63david63 Posts: 7Questions: 0Answers: 0
    I have just done a similar thing, but with the first column.

    One way, and there are probably others, is to add the data that you want manually into the last column of the output data array when you are creating the data in the php file - something along the lines of
    [code] $data[4] = 'my data';[/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Two options:

    1. Do as david63 suggests and add the extra information to the data feed for the table
    2. Use sDefaultContent and set it to an empty string.

    If you want links to an empty page then using mRender would probably be appropriate - use that to create the appropriate link.

    Allan
This discussion has been closed.