繁体   English   中英

使用数据表jquery的codeigniter中的“未定义表数据”

[英]“Undefined table data” in codeigniter using datatables jquery

我一直在尝试将datatables jquery插件与codeigniter一起使用,但仍然没有运气。 我是这个API的新手。 (请没有ignitedTables,只有dataTables jquery插件)。

该视图返回:

未定义表数据

请在下面查看MVC:

VIEW(包含脚本的位置)

<script type="text/javascript">
    $(document).ready(function() {
var oTable = $('#big_table').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "<?php echo site_url('home/calendarListAll/') ?>",
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "iDisplayStart ":20,
            "fnInitComplete": function() {
            //oTable.fnAdjustColumnSizing();
     },
            'fnServerData': function(sSource, aoData, fnCallback)
        {
          $.ajax
          ({
            'dataType': 'json',
            'type'    : 'POST',
            'url'     : sSource,
            'data'    : aoData,
            'success' : fnCallback
          });
        }
        } );
    } );
    </script>

    <html>
    <?php echo $this->table->generate(); ?> //this returns "Undefined table data"
    </html>    

CONTROLLER

function __construct()
{
 parent::__construct();
  $this->load->library('Datatables');
  $this->load->library('table');
  $this->load->database();
  $this->load->helper('url');
  $this->load->helper('form');
  $this->load->helper('html');
}

public function calendarListAll()
{
    $this->load->model('counselor');
    $result = $this->counselor->getCalendar();
    echo $this->datatables->generate($result);
}  

模型

function getCalendar() // get referred_appointments
{

    $counselor_id = $this->session->userdata('counselor_id');

    $query = $this->db->select ('s.first_name as student_fname, s.last_name as student_lname, s.middle_name as student_mname, e.first_name, e.last_name, e.middle_name, re.*, r.student_id, i.*, e.*')
    ->from ('referral as r, student_course_record as scr, curriculum as c, referred_appointment as re, degree as d, course as cc, counselor as ccc,  issue as i, student as s, employee as e')
    ->where ('r.student_id = scr.student_id')
    ->where ('scr.curr_id = c.curr_id')
    ->where ('c.degree_id = d.degree_id')
    ->where ('d.course_id = cc.course_id')
    ->where ('cc.counselor_id = ccc.counselor_id')
    ->where ('r.issue_id = i.issue_id')
    ->where ('r.student_id = s.student_id')
    ->where ('re.referral_id = r.referral_id')
    ->where ('r.employee_id = e.employee_id')
    ->where ('ccc.counselor_id', $counselor_id)
    ->where ('re.status != "C"');
    $ret = $query->get()->result();
    return $ret;

}

使用可能对您有帮助CI帮助

$tmpl = array ('table_open' => '<table id="big_table">');
$this->table->set_template($tmpl);

忘记在generate $ this-> table-> generate($ records);中传递数据;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM