我使用的是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
));
你可以使用beforeAjaxUpdate来获取当前的滚动位置,和afterAjaxUpdate来设置更新后的表:
array(
...
'beforeAjaxUpdate'=>'function(){
position = $("#gridId table").position().left;
}',
'afterAjaxUpdate'=>'function(){
$("#gridId").scrollLeft(position*(-1));
}',
...
)