How to determine if sfdatagrid is scrolled down or up?

I have implemented a floating button in android (it can be normal button also), I want to hide it when sfdatagrid view is scrolled down and show when scrolled up. this is usually done on recyclerview in android using CoordinatorLayout but I am not sure how to do it with sfdatagrid. I appreciate for your help. Thanks

3 Replies

SS Suhasini  Suresh Syncfusion Team April 27, 2017 01:49 PM UTC

Hi Emil, 
 
Thanks for contacting Syncfusion Support. 
 
Your requirement to have a floating button over the datagrid and to handle its visibility based on the scrolling of the datagrid can be achieved by using the ScrollRows_Changed event of the VisualContainer. Please refer the below code example to achieve your requirement. 
 
dataGrid.GridLoaded += DataGrid_GridLoaded; 
 
private void DataGrid_GridLoaded(object sender, GridLoadedEventArgs e) 
{ 
    container = dataGrid.GetType().GetTypeInfo().GetDeclaredProperty("VisualContainer").GetValue(dataGrid) as VisualContainer; 
    container.ScrollRows.Changed += ScrollRows_Changed;             
} 
 
 
private void ScrollRows_Changed(object sender, ScrollChangedEventArgs e) 
{ 
    if (previousOffset > 0) 
    { 
        if (previousOffset > container.VerticalOffset) 
            button.IsVisible = false; 
        else 
            button.IsVisible = true; 
    } 
    else  
    {                
            button.IsVisible = false;                
    } 
    previousOffset = container.VerticalOffset; 
} 
 
 
We have prepared a sample to achieve your requirement, you can download the same from the below link. 
 
 
Regards, 
Suhasini 
 



EM Emil April 27, 2017 02:57 PM UTC

hi Suhasini,

excellent support. thank you very much. this is exactly what i am looking for. thanks

Emil


SS Suhasini  Suresh Syncfusion Team April 28, 2017 11:48 AM UTC

Hi Emil, 
 
Thanks for your update. Please let us know if you need any further assistance. 
 
Regards, 
Suhasini 


Loader.
Up arrow icon