【问题标题】:I am new in codeigniter and I want to add pagination in my data table with ajax我是 codeigniter 的新手,我想用 ajax 在我的数据表中添加分页
【发布时间】:2019-11-09 01:35:28
【问题描述】:

目前我正在使用动态数据表 bootstrap 4,我想在我的表中添加分页

查看:

<form role="form">
        <div class="card-body">
          <div class="row"> 

            <table id="example1" class="table table-bordered table-striped table-sm" >
                <thead>
                <tr>
                  <th>Bilty Id</th>
                  <th>LR No</th>
                  <th>Consignor Name</th>
                  <th>Consignor Gst No</th>
                </tr>

                </thead>
                <tbody>
                  <?php foreach($bilties as $bilty){?>
                <tr>
                  <td><?php echo $bilty->id;?></td>
                  <td><?php echo $bilty->lr_no;?></td>
                  <td><?php echo $bilty->consignor;?></td>
                  <td><?php echo $bilty->consignor_gst_no;?></td>
                  </tr>
                <?php }?>
                </tbody>
              </table>
        </div>
  </div>
</form>

控制器:

public function viewBilty(){
        $this->load->view('template/header');
        $this->load->view('template/sidebar');
        $data= array();

        $this->data['bilties'] = $this->biltyModel->viewBilty();

        $this->load->view('booking/bilty/viewbilty',$this->data);         
        $this->load->view('template/footer');
     }

型号:

public function viewEnableBilty($userid){
            $this->db->select('*');
            $this->db->from('bilty');
            $this->db->where('b.status', 'active');

            $query = $this->db->get();
            return $query->result();
         }

这是我的模型视图控制器我有动态数据表,我想为这个表添加分页

【问题讨论】:

标签: jquery mysql sql ajax codeigniter


【解决方案1】:

添加脚本

https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css

<script>
    $(document).ready(function() {
        $('#example1').DataTable();
    } );
</script>

在你的 html 中

【讨论】:

    猜你喜欢
    • 2015-07-23
    • 1970-01-01
    • 2019-06-11
    • 1970-01-01
    • 2016-06-30
    • 1970-01-01
    • 2020-03-30
    • 1970-01-01
    • 2023-02-03
    相关资源
    最近更新 更多