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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Finding newly inserted row

Thread ID:

Created:

Updated:

Platform:

Replies:

114775 Dec 8,2013 05:45 AM UTC Dec 10,2013 12:03 PM UTC WPF 3
loading
Tags: GridControl
Joshua Cauble
Asked On December 8, 2013 05:45 AM UTC

I am using the GridDataControl for WPF and I am trying to setup a process that does the following:

1) When Adding a record, set focus to column x of the new row.
2) When duplicating a record, set focus to column y of the new row.

I am using an MVVM application and have an observablecollection I am bound to.  The VM will add the new record to the datasource and it shows in the grid.  What I need is to be able to set focus to this new row and then set focus to a specific column in that row.

The grid is sortable so it's possible that the new row is not in position of RowCount -1.  Thus the frustration.  :)

I have been hunting but have had no luck finding a solution.

Any help would be greatly appreciated.

Shakul Hameed M [Syncfusion]
Replied On December 9, 2013 12:45 PM UTC

Hi Joshua,

 

Thanks for contacting Syncfusion.

We have analyzed your query and we can achieve your requirement by using the below code.

 

Please refer the following code snippet.

 

Code Snippet:

void View_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

        {

            if(NotifyCollectionChangedAction.Add==e.Action)

            {           

                var index = e.NewStartingIndex;

                var rowIndex = this.GridDataControl1.Model.ResolvePositionToIndex(index);

                var record=e.NewItems[0] as Person;

 

                var records = this.GridDataControl1.Model.View.Records;

                var result = from c in records

                             where (c.Data as Person).No == record.No

                             select c;

 

                if (result.Count() >= 2)

                {

                    this.GridDataControl1.Model.Grid.CurrentCell.MoveTo(rowIndex,1);                   

                    this.GridDataControl1.Model.Grid.CurrentCell.BeginEdit();

                }

                else

                {

                    this.GridDataControl1.Model.Grid.CurrentCell.MoveTo(rowIndex, 0);

                    this.GridDataControl1.Model.Grid.CurrentCell.BeginEdit();

                }        

            }

        }

 

We can get the exact record position by listening the Collection Changed event, even the grid is in sort.

 

And I have moved the current cell to that new record position by using MoveTo method. If the newly added record contains a unique No means the current cell position moved to the first column,

if it’s a duplicate row, then it moves to the second column.

 

We have prepared a sample based on your requirement. Please find the sample from the below location.

 

Sample: GridDataControl Row Positioning.zip

 

Please let us know, if you have any queries.

 

Thanks,

Shakul Hameed


Joshua Cauble
Replied On December 9, 2013 11:34 PM UTC

This sample was perfect!  I figured that event might have something to do with that but was getting lost on the other functions.  Thanks for the help.

Shakul Hameed M [Syncfusion]
Replied On December 10, 2013 12:03 PM UTC

Hi Joshua,

 

Thanks for your update.

Please let us know if you require further assistance from us.

 

Thanks,

Shakul Hameed


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.

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

;