EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: MB34 on April 30, 2015, 10:05:20 AM



Title: Scroll record to top of view when expanding?
Post by: MB34 on April 30, 2015, 10:05:20 AM
I'm using the crud example. Is there a way to make the row scroll to the top of the view when expanding the row to edit it?

As shown in my other post, scrollTo() doesn't work for me at all, no matter where I put it.


Title: Re: Scroll record to top of view when expanding?
Post by: MB34 on April 30, 2015, 12:13:22 PM
I used another jQuery plugin called jQuery-ScrollTo, http://balupton.github.io/jquery-scrollto/ to do this.

In case you are wondering how. I did this in the onLoad for the ddv.panel:

Code:
var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv');
ddv.panel({
    border:false,
    cache:true,
    href:'show_form.php?index='+index,
    onLoad:function(){
        $('#dg').datagrid('fixDetailRowHeight',index);
        $('#dg').datagrid('selectRow',index);
        $('#dg').datagrid('getRowDetail',index).find('form').form('load',row);
        ddv.ScrollTo({duration: 0,easing: 'linear',offsetTop: 26}); // This scrolls the current row to the top of the view.
    }
});

If someone has an answer on how to do this without the other plugin, let me know, otherwise, I'm marking this as solved.