【问题标题】:How to fix the horizontal Scroll bar position on CGRIDVIEW YII?如何修复 CGRIDVIEW YII 上的水平滚动条位置?
【发布时间】:2014-05-29 13:59:57
【问题描述】:

我正在使用 CGRIDVIEW

假设 gridview 中有 20 列,所以水平滚动条会出现在图片中

如果我想对第 20 列进行排序,我必须滚动条才能到达那里

当我对该列进行排序时,gridview 会重新加载,

所以水平滚动条失去了它的位置并回到原来的位置

如何在gridview排序后才在第20列制作滚动条

这里是 GridView -->

$this->widget('bootstrap.widgets.TbGridView', array(
            'type' => 'bordered striped',
            'id' => 'bike_search_grid',   
            'dataProvider' => $model->search_bike(),
            'ajaxUpdate' => true, //false if you want to reload aentire page (useful if sorting has an effect to other widgets)
            'filter' => null, 
            'template'=>'<div style="overflow:auto;">{items}</div>{pager}{summary}',
            'columns' => $selected_columns,
            'enablePagination' => true
        ));

【问题讨论】:

    标签: php sorting yii scrollbar cgridview


    【解决方案1】:

    您可以使用beforeAjaxUpdate获取当前滚动位置,并在更新表格后使用afterAjaxUpdate设置它:

     array(
        ...
        'beforeAjaxUpdate'=>'function(){
            position = $("#gridId table").position().left;
        }',
        'afterAjaxUpdate'=>'function(){
            $("#gridId").scrollLeft(position*(-1));
        }',
        ...
     )
    

    【讨论】:

    • 很抱歉,,,,但是这个解决方案没有给我想要的结果......感谢更多帮助!
    • @user3134101 您使用哪个网格 ID(而不是 gridId)?
    • @user3134101 尝试使用这种方法:'beforeAjaxUpdate'=&gt;'function(id){ scroll = $("#"+id).scrollLeft(); }', 'afterAjaxUpdate'=&gt;'function(id){ $("#"+id).scrollLeft(scroll); }',
    • @user3134101 我最后的建议怎么样?有用吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多