Jquery DataTables not working when am using a foreach loop

Jquery DataTables not working when am using a foreach loop

duladula Posts: 3Questions: 1Answers: 0
edited February 2016 in Free community support

My Jquery DataTables is not working when am using a foreach loop to display data on a table in multiple bootstrap tabs. Here is my code

<table class="table table-bordered display" id="dailyentriesList">
        <thead>
        <tr>
            <?php if (isset($this->items[0]->state)): ?>
                
            <?php endif; ?>

                            <th class=''>
                <?php echo JHtml::_('grid.sort',  'COM_ADSENSEREPORTING_DAILYENTRIESS_EXCEL_DATE', 'a.date', $listDirn, $listOrder); ?>
                </th>
                <th class=''>
                <?php echo JHtml::_('grid.sort',  'COM_ADSENSEREPORTING_DAILYENTRIESS_PAGE_VIEWS', 'a.pageviews', $listDirn, $listOrder); ?>
                </th>
                <th class=''>
                <?php echo JHtml::_('grid.sort',  'COM_ADSENSEREPORTING_DAILYENTRIESS_IMPRESSIONS', 'a.impressions', $listDirn, $listOrder); ?>
                </th>
                <th class=''>
                <?php echo JHtml::_('grid.sort',  'COM_ADSENSEREPORTING_DAILYENTRIESS_CLICKS', 'a.clicks', $listDirn, $listOrder); ?>
                </th>
                <th class=''>
                <?php echo JHtml::_('grid.sort',  'COM_ADSENSEREPORTING_DAILYENTRIESS_PAGE_RPM', 'a.pagerpm', $listDirn, $listOrder); ?>
                </th>
                <th class=''>
                <?php echo JHtml::_('grid.sort',  'COM_ADSENSEREPORTING_DAILYENTRIESS_IMPRESSION_RPM', 'a.impressionrpm', $listDirn, $listOrder); ?>
                </th>
                <th class=''>
                <?php echo JHtml::_('grid.sort',  'COM_ADSENSEREPORTING_DAILYENTRIESS_ACTIVE_VIEW_TABLE', 'a.activeviewtable', $listDirn, $listOrder); ?>
                </th>
                <th class=''>
                <?php echo JHtml::_('grid.sort',  'COM_ADSENSEREPORTING_DAILYENTRIESS_ESTIMATED_EARNINGS', 'a.earnings', $listDirn, $listOrder); ?>
                </th>

        </tr>
        </thead>
        <tfoot>
        <tr>
            <td colspan="<?php echo isset($this->items[0]) ? count(get_object_vars($this->items[0])) : 10; ?>">
                <?php echo $this->pagination->getListFooter(); ?>
            </td>
        </tr>
        </tfoot>
        <tbody>
        <?php foreach ($this->items as $i => $item) : ?>
            <?php $canEdit = $user->authorise('core.edit', 'com_adsensereporting'); ?>

            
            <tr class="row<?php echo $i % 2; ?>">

                <?php if (isset($this->items[0]->state)) : ?>
                    <?php $class = ($canEdit || $canChange) ? 'active' : 'disabled'; ?>
                    
                <?php endif; ?>

                <td>
                    <?php echo $item->date; ?>
                </td>
                <td>
                    <?php echo $item->pageviews; ?>
                </td>
                <td>

                    <?php echo $item->impressions; ?>
                </td>
                <td>

                    <?php echo $item->clicks; ?>
                </td>
                <td>

                    <?php echo $item->pagerpm; ?>
                </td>
                <td>

                    <?php echo $item->impressionrpm; ?>
                </td>
                <td>

                    <?php echo $item->activeviewtable; ?>
                </td>
                <td>

                    <?php echo $item->earnings; ?>
                </td>

            </tr>
        <?php endforeach; ?>
        </tbody>
    </table> 

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page], if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • duladula Posts: 3Questions: 1Answers: 0

    In order for you to see the page one has to login..bc it fetches data from the db...

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin
    Answer ✓

    You can drop me a PM by clicking my name above and then "Send message".

    Allan

  • duladula Posts: 3Questions: 1Answers: 0

    Okay. Sure thing

This discussion has been closed.