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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

What is the equivalent of AfterRowLoaded event in sfDataGrid.

Thread ID:

Created:

Updated:

Platform:

Replies:

145670 Jul 3,2019 06:51 AM UTC Jul 9,2019 01:56 PM UTC WPF 3
loading
Tags: SfDataGrid
Qasim Raza
Asked On July 3, 2019 07:29 AM UTC

What are the equivalent of AfterRowLoaded and RowActivated events in sfDataGrid.

I hope at least I will get the answer of this question otherwise, its useless if I get an answer in a week or so.

Farjana Parveen Ayubb [Syncfusion]
Replied On July 4, 2019 08:57 AM UTC

Hi Qasim, 
  
Thank you for contacting Syncfusion Support. 
  
We have analyzed your query. Your requirement to get row added at runtime by using SfDataGrid.View.Records.CollectionChanged event which will fire whenever the underlying collection is changed. Also when row is selected, SfDataGrid.CurrentCellActivating event will be fired. Please refer the below code snippet  
  
public class CustomBehavior : Behavior<SfDataGrid> 
    { 
        protected override void OnAttached() 
        { 
            this.AssociatedObject.Loaded += AssociatedObject_Loaded; 
            this.AssociatedObject.CurrentCellActivating += AssociatedObject_CurrentCellActivating; 
        } 
  
        private void AssociatedObject_CurrentCellActivating(object sender, CurrentCellActivatingEventArgs e) 
        { 
            var rowIndex = e.CurrentRowColumnIndex.RowIndex; 
            var dataRow = AssociatedObject.RowGenerator.Items.FirstOrDefault(row => row.RowIndex == rowIndex) as DataRow; 
            //you can write your own code here. 
        } 
  
        private void AssociatedObject_Loaded(object sender, System.Windows.RoutedEventArgs e) 
        { 
            this.AssociatedObject.View.Records.CollectionChanged += Records_CollectionChanged; 
        } 
  
        private void Records_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) 
        { 
            if (e.Action == NotifyCollectionChangedAction.Add) 
            { 
                var rowIndex =this.AssociatedObject.ResolveToRowIndex(e.NewItems[0]); 
                this.AssociatedObject.ScrollInView(new RowColumnIndex(rowIndex,this.AssociatedObject.GetFirstColumnIndex())); 
                AssociatedObject.Dispatcher.BeginInvoke(DispatcherPriority.Background, 
                    new Action(() => 
                    { 
                        var dataRow = AssociatedObject.RowGenerator.Items.FirstOrDefault(row => row.RowIndex == rowIndex) as DataRow; 
                        //you can write your own code here. 
                    })); 
            } 
        } 
    } 
  
Please find sample for the same from below link and let us know if this helps you,  
 
  
If the above events does not meet your requirement, please let us know your exact requirement on what action you would like to do with SfDataGrid once the row was loaded. If you provide those details only we could know and suggest the exact event for your required action. 
  
Regards, 
Farjana Parveen A 


Qasim Raza
Replied On July 8, 2019 07:15 AM UTC

HI

No this is not what I was looking into. Let me repharase my question.

"When a row in a grid is loaded, in default WPF framework we have an event named "AfterRowLoaded". Which get fires.
this help us to make for example some row level formating.

As per the default description of WPF core framework. it says

AfterRowLoaded occurs after a row is loaded.


Now can you please share the detail of event that is equivalent to this behavior or replica of this even in SyncFusion sfDataGrid along with some example.





Shobika Palani [Syncfusion]
Replied On July 9, 2019 01:56 PM UTC

Hi Qasim, 

Thanks for the update. 

SfDataGrid does not have event equivalent to AfterRowLoaded. On further analyzing your requirement to apply formatting in row level, you can write style targeting VirtualizingCellsControl. Please refer to the below UG links and KB articles to know more details on styling rows 

UG Links: 

KB Links: 

If above articles does not meet your requirement, please let us know your exact requirement on how you want to apply row level formatting in your grid. It will helps us to investigate further and provide earlier prompt solution. 

Regards, 
Shobika. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon