【问题标题】:How can keep checked row selected during pagination in Yii?如何在 Yii 的分页期间保持选中的行?
【发布时间】:2014-02-10 05:59:08
【问题描述】:

我正在使用分页来查看表格行。我想从不同的页面中选择不同的行,然后提交表单。

但是当我从一个页面中选择不同的行并移动到另一个页面以选择更多然后再次返回上一页时,我没有在那里找到已经检查过的行。

这是我的代码-

<table class="table">
    <tr>
        <th></th>
        <th>Name</th>
    </tr>
    <?php
    $j=0;   
    foreach($datavalue as $datainarray)
    {
        ?>
        <tr>
            <td>
                <input type="checkbox" id="item_id[<?php echo $j; ?>]" name="item_id[<?php echo $j; ?>]" 
                value="<?php echo $datainarray->attributes['item_id']; ?>">
            </td>

            <td><?php echo $datainarray->attributes['Name'];?></td>
        </tr>
        <?php
        $j++;   
    }
    ?>
</table>

<?php
    $this->widget('CLinkPager', array(
         'itemCount'=>$row_count,
         'pageSize'=>20,
         'maxButtonCount'=> 10,
         'nextPageLabel'=>'Next >>',
         'header' => '',
    ));     
?>

我在网上搜索过解决方案,但没有找到合适的解决方案。

希望从专家那里找到合适的解决方案。

谢谢

【问题讨论】:

  • 您需要存储选中元素的详细信息,然后在加载新页面时检查是否显示了任何已选中的项目,然后再次将它们标记为已选中
  • 请您按照您的想法写出解决方案。
  • 你需要分享你的分页逻辑和html

标签: php jquery html yii pagination


【解决方案1】:

当行被选中时,将选定的行 id 存储到数组中,当加载上一页时,然后根据数组的值选择这些行。

【讨论】:

    猜你喜欢
    • 2020-03-20
    • 1970-01-01
    • 2021-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多