dongle3217 2014-10-27 21:02
浏览 5
已采纳

使用Cygnite Framework分页将行号增加到网格中

I am using Cygnite PHP Framework and generated CRUD application using Cygnite CRUD generator. I changed pagination limit to 10 per page in my model class.

Now the problem is,

In the first page serial number is displaying 1-10 but when I am clicking on the next page, though records are different it is reseting the serial number back to 1-10 again. It should be (Second page) 11-20.

My view page:

<?php

if (count($this->records) > 0) {
    $i = 1;
    $rowType = null;
    foreach ($this->records as $key => $value) {

        $rowType = ($i % 2 == 0) ? 'even' : 'odd';
        ?>
      <tr class='<?php echo $rowType; ?>'>
          <td> <?php echo $i; ?></td>
           ..............
      </tr>

    }

}

?>

<div ><?php echo $this->links; ?> </div>

How to fix it ?

Thanks!

  • 写回答

1条回答 默认 最新

  • duancai7002 2014-10-28 17:42
    关注

    Hope below code will help you.

    Step1: Open /apps/views/user/index.view.php

    Step 2: In this page inside top of the view page add below code to include.

    use Cygnite\Common\UrlManager\Url; 
    use Apps\Models\User; 
    
    $user = new User; 
    

    Step 3: Now go inside if condition

    if (count($this->records) > 0) { 
    

    replace $i with below code.

    if (Url::segment(2) == '' || Url::segment(3) == '' || Url::segment(3) == 1 ) { 
        $i =1; 
    } else { 
        $i = (Url::segment(3) - 1) * $user->perPage + 1; 
    } 
    

    Step 4: That's all. Now run the application it will display serial number correctly into the grid.

    Cheers!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程