Get row details from a column which is not shown?

Get row details from a column which is not shown?

Rawland_HustleRawland_Hustle Posts: 94Questions: 16Answers: 0
edited April 2014 in DataTables 1.10
Hi!

My knowledge of coding is basically zero, but I've somehow managed to use the "hidden row details example" and after several hours of trail and error I've almost got it to work :) I've got a MySQL database from which I'm getting data to display in DataTables. To do that, I'm using this code I found (below).

What I'd like to get help with is to have "hidden row details" show information from my database which is NOT shown in the table. When I click the plus sign, I want DataTables to get data from, let's say, column 7. But I don't want column 7 to be visible in the table. I just want the first 3 columns to be shown (like below).

Thanks! :)

[code]
<?php
$dbhost = 'hidden';
$dbuser = 'hidden';
$dbpass = 'hidden';
$dbname = 'hidden';

// Create connection
$con=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

$result = mysqli_query($con,"SELECT * FROM world");

echo "


Column1
Column2
Column3

";

while($row = mysqli_fetch_array($result))
{
echo "";
echo "" . $row['country'] . "";
echo "" . $row['city'] . "";
echo "" . $row['population'] . "";
echo "";
}
echo "";

mysqli_close($con);
?>
[/code]

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    If you are outputting your table like that, you need to include all 7 columns and then use the bVisible option to hide the ones you don't want. This is so DataTables is able to read the data for the whole row - otherwise it can't know about it (you could use `data-*` attributes in fairness, but let's stick with simple for the moment!).

    Then use fnGetData to get the data array for the whole row.

    Allan
  • Rawland_HustleRawland_Hustle Posts: 94Questions: 16Answers: 0
    Thanks allan, bVisible worked great!

    Your help is appreciated!
This discussion has been closed.