在CI阿贾克斯jQuery的分页错误分页、错误、CI、阿贾克斯

2023-09-10 13:18:25 作者:在外语中英文可以说是最受欢迎的,今日小编为小伙伴们带来网红英

在codeigniter jQuery的分页遇到错误。

 如果per_page = 5;
    总数6和总第2页

    但是像下面的分页

    显示6 6 6 | < 1 2
    但只有5所示,并在第二页最后一个节目。
 

喜的朋友,我陷在这个bug.This显示在每一个pages.Pls给我一个解决方案,以获得正确的分页

低于code使用:

  $配置['BASE_URL'] = SITE_URL(设置/ view_leave_reason_ajax /');
        $配置['total_rows'] = $这个 - > leav-> getLvReasonCount();
        $配置['per_page'] = 5;
        $配置['anchor_class'] ='ajax_links';
        $配置['show_count'] =真;
        $配置['格'] ='#list_view';
        $这个 - > jquery_pagination->初始化($配置);
        $页=($这 - > URI的>段(3))? $这 - > URI的>链段(3):0;
        $数据[链接] = $这个 - > jquery_pagination-> create_links();
        $数据['页'] = $页;
        $数据['结果'] = $这个 - > leav-> getLvReason($配置[per_page],$页);
 

对于低于CI分页问题:

https://github.com/neotohin/$c$cIgniter-Ajax-pagination-Library

上港输在哪里 1球员错误操作令人失望,外援挥手表示无奈

查看页面:

 <如果PHP($结果==)
                {&GT?;
                < TR风格=高度:50像素;背景:#FFFFFF;字体重量:大胆;>
                    < TD合并单元格=5的风格=宽度:50像素;>
                        无详细信息的存在
                    < / TD>
                < / TR>
                < PHP
                }
                如果($结果!=)
                {
                $ C = $页+ 1;
                $的col1 [1] =;
                $的col1 [2] =#d6e3f6;
                $ COL = $的col1 [2];
                    的foreach($结果为$行)
                    {
                        $做= $行['身份证'];
                ?>
                < TR风格=高度:50像素;背景:??< PHP的echo $关口;取代;>
                    < TD><输入类型=复选框名称=C1 []值=< PHP的echo $做;>中/>< / TD>
                    < TD>< PHP的echo $ C;?>< / TD>
                    < TD>< PHP的echo $行['部门名称'];?>< / TD>
                    < TD>

                            <一类=的fancybox fancybox.iframe的href =<?PHP的回声SITE_URL()/设置/ department_edit /".$这 - > hrm-> encData($行['身份证']) ;?>中>< IMG类=艾康SRC =< PHP的回声BASE_URL()'/资产/图像/ edit.png';?>中宽度=20标题=编辑的风格=的margin-top:4PX;保证金左:的3px;>< / A>
                    < / TD>
                < / TR>
                < PHP $ C $ = C + 1;
                如果($ COL == $的col1 [1])$ ​​COL = $的col1 [2];
                否则$ COL = $的col1 [1];
                    }

                ?>
                < TR风格=高度:50像素;背景:#FFFFFF;字体重量:大胆;>
                    < TD合并单元格=5的风格=宽度:50像素;>
                        <输入类型=按钮值=删除级=btn_black的onclick =返回chkdel()>
                    < / TD>
                < / TR>
                < PHP}&GT?;

                < TR风格=高度:50像素;>< TD合并单元格=4的风格=文本对齐:右;填充右:10px的;>< PHP的echo $链接; ?>< / TD>< / TR>
 

解决方案

您已经定义

  $配置['格'] ='#list_view';
 

在你的配置,但你没有定义的容器视图。因此,没有Ajax调用将被发送。

而不是此

于是

 < TR风格=高度:50像素;>< TD合并单元格=4的风格=文本对齐:右;填充右:10px的;&GT ;< PHP的echo $联系; ?>< / TD>< / TR>
 

尝试把容器< D​​IV ID =list_view>< PHP的echo $联系; ?>< / DIV> 如下:

 < TR风格=高度:50像素;>< TD合并单元格=4的风格=文本对齐:右;填充右:10px的;&GT ;< D​​IV ID =list_view>< PHP的echo $联系; ?>< / DIV>< / TD>< / TR>
 

在分页库还 Jquery_pagination.php

在改变这一行行号184

 如果(($ curr_offset + $这个 - > per_page)≤($这个 - > total_rows -1))
 

 如果(($ curr_offset + $这个 - > per_page)< =($这个 - > total_rows -1))
 

这将是工作...

Got error in jquery pagination in codeigniter.

    if per_page=5;
    total number 6 and total page 2

    but the pagination like below

    Showing 6 to 6 of 6 |  < 1 2
    But only 5 is shown and last one show in 2nd page.

Hi friends i am stuck in this bug.This show in every pages.Pls give me a solution to get correct pagination

below code is using:

            $config['base_url'] = site_url('settings/view_leave_reason_ajax/');
        $config['total_rows'] = $this->leav->getLvReasonCount();
        $config['per_page'] = 5;        
        $config['anchor_class'] = 'ajax_links';
        $config['show_count'] = true;
        $config['div'] = '#list_view';
        $this->jquery_pagination->initialize($config);
        $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
        $data["links"] = $this->jquery_pagination->create_links();
        $data['page'] = $page;
        $data['result'] = $this->leav->getLvReason($config["per_page"], $page);

question regarding the below ci pagination:

https://github.com/neotohin/CodeIgniter-Ajax-pagination-Library

view page:

<?php if($result=="")
                {?>
                <tr style="height: 50px; background:#ffffff; font-weight: bold;">
                    <td colspan="5" style="width:50px;">
                        No Details Exist
                    </td>
                </tr>
                <?php
                }
                if($result!="")
                {
                $c = $page+1;
                $col1[1]="";
                $col1[2]="#d6e3f6";
                $col=$col1[2];
                    foreach ($result as $row)
                    {
                        $did = $row['id'];
                ?>
                <tr style="height: 50px;background:<?php echo $col;?>;">
                    <td><input type="checkbox" name="c1[]"  value="<?php echo $did;?>" /></td>
                    <td><?php echo $c;?></td>
                    <td><?php echo $row['department_name'];?></td>
                    <td>

                            <a class="fancybox fancybox.iframe" href="<?php echo site_url()."/settings/department_edit/".$this->hrm->encData($row['id']); ?>" ><img class="aicon" src="<?php echo base_url().'/assets/images/edit.png';?>" width="20" title="edit" style="margin-top:4px; margin-left:3px;"></a>
                    </td>   
                </tr>
                <?php  $c=$c+1;
                if($col == $col1[1])    $col = $col1[2];
                else $col = $col1[1];
                    }

                ?>
                <tr style="height: 50px; background:#ffffff; font-weight: bold;">
                    <td colspan="5" style="width:50px;">
                        <input type="button" value="Delete" class="btn_black" onclick="return chkdel()">
                    </td>
                </tr>
                <?php }?>

                <tr  style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><?php echo $links; ?></td></tr>

解决方案

You have defined

 $config['div'] = '#list_view';

in your config, but you haven't defined that container in your view. Hence no ajax calls will be sent.

So instead of this

<tr  style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><?php echo $links; ?></td></tr>

Try putting the container <div id="list_view"><?php echo $links; ?></div> as below:

<tr  style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><div id="list_view"><?php echo $links; ?></div></td></tr>

Also in the pagination library Jquery_pagination.php

change this line at line number 184 from

if( ( $curr_offset + $this->per_page ) < ( $this->total_rows -1 ) )

to

if( ( $curr_offset + $this->per_page ) <= ( $this->total_rows -1 ) )

And it will be working...