【问题标题】:how to perform sorting,search,pagination in codeigniter如何在codeigniter中执行排序、搜索、分页
【发布时间】:2016-01-30 12:47:05
【问题描述】:

我是 codeigniter 的新手。我想搜索、排序并将分页应用于我的表格。 我尽力了。当搜索代码工作时,排序可能不起作用。我不能在一个表中执行这三个操作。请帮我。

【问题讨论】:

标签: codeigniter sorting search pagination


【解决方案1】:

使用Bootstrap datatables。它也有内置的搜索、排序和分页功能。


我的代码示例

可见

<div style="clear: both; margin-top: 35px"></div>
<div class="container">
    <div class="col-sm-12" style="padding: 0px">
        <div class="row">
            <div class="col-sm-10 col-sm-offset-1 " style="padding-right:0px;">
                <table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">

                    <thead>
                    <tr>
                        <th width="20%"></th>
                        <th width="15%"></th>
                        <th width="20%"></th>
                        <th width="15%"></th>
                        <th width="10%"></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?
                        foreach ( $ as $ )
                        {
                            ?>
                            <tr>
                                <td><?php echo $['']?></td>
                                <td><?php echo $['']?></td>
                                <td><?php echo $['']?></td>
                                <td><?php echo $['']?></td>
                            </tr>
                        <?
                        }

                    ?>

                    </tbody>
                </table>
            </div>

        </div>
    </div>
</div>

在控制器中

$data[''] = $this->model_name->function_name();

在标题中

<link href="<?php echo base_url(); ?>css/bootstrap.css" rel="stylesheet" /> 
<link href="<?php echo base_url(); ?>css/bootstrap-glyphicons.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet" />

输出

【讨论】:

  • @ Abdulla 是的.. 这真的很有帮助。 :)
  • @SaranyaR 乐于提供帮助 :) 享受编码
  • @SaranyaR 这也添加了bootstrap-glyphicons.css。可以在引导站点下载
猜你喜欢
  • 1970-01-01
  • 2023-03-20
  • 1970-01-01
  • 1970-01-01
  • 2016-06-15
  • 2012-05-15
  • 1970-01-01
  • 2016-03-21
  • 2017-12-20
相关资源
最近更新 更多