We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to get reference to the VisualContainer of a SfDataGrid?


I follow this ticket  #  142708 to update the SfListView content,  reserving the current view. It works perfect.

How can i achieve the same thing with SfDataGrid?

SfDataGridHeHelpers doesn't have GetVisualContainer as SfListView does.

Thank you.

4 Replies

KK Karthikraja Kalaimani Syncfusion Team October 7, 2019 01:27 PM UTC

Hi Tung,

 
Thanks for contacting Syncfusion support.

We have prepared sample for your reported query “How to get VisualContainer of SfDataGrid”. Please follow the below code snippet and sample.


 
[.CS] 
double yPosition; 
        ExtendedScrollView ScrollView; 
        AndroidScrollView androidScrollView; 
        public MainPage() 
        { 
            InitializeComponent(); 
           
            dataGrid.GridLoaded += DataGrid_GridLoaded; 
        } 
 
        private async void DataGrid_GridLoaded(object sender, GridLoadedEventArgs e) 
        { 
            var container =(VisualContainer) dataGrid.GetType().GetProperty("VisualContainer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(dataGrid); 
 
            if (Device.RuntimePlatform == Device.Android) 
            { 
                androidScrollView = (AndroidScrollView)container.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == "AndroidScrollOwner").GetValue(container); 
            } 
            else 
            { 
                ScrollView = (ExtendedScrollView)container.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == "ScrollOwner").GetValue(container); 
            } 
        } 
 
        private void Button_Clicked(object sender, EventArgs e) 
        { 
            if (Device.RuntimePlatform == Device.Android) 
            { 
                yPosition = androidScrollView.ScrollY; 
            } 
            else 
            { 
                yPosition = ScrollView.ScrollY; 
            }    
        } 
 
        private async void Button_Clicked_1(object sender, EventArgs e) 
        { 
            if (Device.RuntimePlatform == Device.Android) 
            { 
                await (androidScrollView as ExtScrollViewer).ScrollToAsync(0, yPosition,false); 
            } 
            else 
            { 
                await (ScrollView as ScrollView).ScrollToAsync(0, yPosition,false); 
            } 
        } 
 
 
 
 
 
Please let us know, if you need any further assistance from us. 
 
 
Regards, 
Karthik Raja 



TU Tung October 10, 2019 02:09 AM UTC

Thank you for the sample,

It works fine at my end. 

Do you plan to add this function to the Helper to remove all complexity with reflection ?




BS Balasubramani Sundaram Syncfusion Team October 10, 2019 10:18 PM UTC

Hi Tung,   
  
Thanks for the update,   
 
We have logged a feature request of “Accessing a visual control generic” for the same and we will implement this feature and we will include in our upcoming 2019 Volume 3 SP1 release which is estimated to be available on end of November. We appreciate your patience until then.  
  
We will provide the feedback link on October 11th, 2019 from that you can track the status of the report.  
  
Regards,   
Balasubramani Sundaram.  



FP Farjana Parveen Ayubb Syncfusion Team October 11, 2019 10:58 AM UTC

Hi Tung,

Thank you for your patience.

As we promised earlier the requested feature is included in our 2019 Volume 3 SP1, which is available in end of November 2019. For further details, please follow the feedback link,  
 
  
 
Note: The provided feedback link is private, and you need to login to view this feedback. 
 
Regards,   
Farjana Parveen A 


Loader.
Up arrow icon