0

I'm having the biggest headache with this code....

Im trying to show the data correctly but it's not showing as i want...

Hope you can help me out....

I have the HTML:

<table border="0" cellpadding="4" cellspacing="0" class="display" id="results">
        <thead>
            <tr>
                <th width="10%">Id</th>
                <th width="10%">Time</th>
                <th width="10%">User</th>
                <th width="10%">Name</th>
                <th width="10%">Email</th>
                <th width="10%">Points</th>
                <th width="10%">Result</th>
                <th width="10%">Delete</th>

            </tr>
        </thead>
        <tbody>
            <tr>
                
            </tr>
        </tbody>
    </table>

Have the Script:

<script type="text/javascript" charset="utf-8">
    $(document).ready(function()
    {
        var oTable = $('#results').dataTable
        ({
            "bJQueryUI": true,
            "bProcessing": true,
            "sPaginationType": "full_numbers",
            'bServerSide'    : true,
            "bDeferRender": true,
            'sAjaxSource'    : '<?php echo base_url(); ?>manage/quiz/read_results/<?php echo $id_quiz; ?>',

            "fnServerData": function ( sSource, aoData, fnCallback ) {

                $.ajax( {
                    "dataType": 'json',
                    "type": "POST",
                    "url": sSource,
                    "data": aoData,
                    "success":fnCallback
                
                });
            }

        });
    });
</script>

Have the PHP Code:

function read_results($id = '') {


        $this->load->library(array("Datatables"));

        $this->datatables->select('
                    quiz_results.id as rid,
                    quiz_results.ts as time,
                    quiz_fbusers.pic as img,
                    quiz_fbusers.name as fb_name,
                    quiz_fbusers.email as fb_email,
                    quiz_results.points as fb_points,
                    quiz_results.result as fb_results')
                ->from('quiz_results')
                ->join('quiz_fbusers', 'quiz_results.fb_id = quiz_fbusers.fb_id')
                ->where('quiz_results.id_quiz =', $id);

        $this->datatables->add_column('Id', '$1', 'rid')
                ->add_column('Time', '$1', 'time')
                ->add_column('User', '<img src="$1">', 'img')
                ->add_column('Name', '<center>$1</center>', 'fb_name')
                ->add_column('Email', '<center>$1</center>', 'fb_email')
                ->add_column('Points', '<center>$1</center>', 'fb_points')
                ->add_column('Result', '<center>$1</center>', 'fb_results')
                ->add_column('Delete', '<center><a href="' . base_url() . 'manage/quiz/delete_participation/$1" class="delete_participation" info="$2"><img src="' . base_url() . '_assets/images/admin/remove_option.png"></a></center>', 'rid,fb_name');

        echo $this->datatables->generate();
    }

The issue:

I have more or less the same code for other tables and it works perfectly... the difference is that this one has a JOIN and the add columns are not showing what i want them to show as you can see from the picture attached....

Attachments datatables_issue.jpg 21.88 KB
1
Contributor
1
Reply
4
Views
5 Years
Discussion Span
Last Post by ALFA-FOXTROT
0

$this->datatables->edit_column('img', '<img src="$1">', 'img')

The edit_column first paramenter is related to the DB colloum and not the <TABLE> <tr> <td> collumn you are trying to change....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.