DataTables could not be implemented in repeating tables

DataTables could not be implemented in repeating tables

mfaizmzakimfaizmzaki Posts: 1Questions: 0Answers: 0
edited February 2014 in DataTables 1.9
Hello, I have the following code (table_view.php) which serves as the default table for the site. All data in the site that is to be represented in a table will be calling the function from table_view.php. Meaning to say, it could be called repeatedly by different datasets. For instance, on a page, there could be 5 different tables with 5 different datasets but all calling from the same function. This will make all the tables having the same table id (since it is called from the same file table-view.php)

[code]
<!DOCTYPE html>









<?php
$row_id="";
if($_GET['page']==1 || isset($_GET['page'])==false){
$row_id=1;
}elseif (isset($_GET['page']) && $_GET['page']>1) {
$row_id=($_GET['page']-1)."1";
}

$doc = JFactory::getDocument();

$doc->addScript('http://code.jquery.com/jquery-1.11.0.min.js');
$doc->addScript('http://datatables.net/download/build/nightly/jquery.dataTables.js');

$doc->addScriptDeclaration('
jQuery(document).ready( function () {
jQuery("#main-table").DataTable();
});
');
?>
<?php echo $this->title ?>

tableWidth)) echo 'width="'.$this->tableWidth.'"';?> >

<?php
if(!$this->hideHeaderTable)
{

if($_GET['t']!='maklumat_ringkas'){
echo "Bil";
}


foreach($this->tableData[0] as $key=>$tableHeader)
{
?>
<?php echo $this->tableData[0][$key] ?>
<?php
}
?>


<?php
}


$lenData = count($this->tableData);

for ($j=3;$j < $lenData; ++$j)
{
?>
><?php if($_GET['t']!='maklumat_ringkas'){echo "".$row_id++."";}?>
<?php
foreach($this->tableData[0] as $key=>$tableHeader)
{
?>
tableData[2][$key] ?>><?php echo stripslashes($this->tableData[$j][$key]) ?>
<?php
}
?>

<?php
}

?>
<!--
JUMLAH
 
 
-->



[/code]

However, I only managed to implement DataTables on the first occuring table. The remaining tables remain the same without DataTables. How can I implement DataTables on all of the tables on the page since they've all got the same table id?
This discussion has been closed.