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

Grid with ObservableCollection ItemsSource: Iterate over records

Thread ID:

Created:

Updated:

Platform:

Replies:

105783 Nov 19,2012 11:04 AM UTC Dec 26,2012 10:40 AM UTC WPF 1
loading
Tags: GridControl
Friedrich
Asked On November 19, 2012 11:04 AM UTC

Hi,

I have a Syncfusion WPF grid with an ObservableColletion<T> as data source with columns A, B, and C.  The grid is grouped and sorted by column A, lets say 3 items in the A group and 5 items in the B group and 2 in the C group.   I want to create a command that will iterate through the records in such a way that the first record under A [0-based index=0] is selected first.  Invoking the command again should highlight the first item in group B
[index=3].  Invoking it a third time the selection and the selected highlight should move to the first item in the C group [index=8].

In the Xaml I have:
SelectedItem="{Binding Item, Mode=TwoWay}"

I would expect that assigning the SelectedItem in the ViewModel in through code would change the selected item and highlight.  This does not seem to work :(

I then tried to select record with index 3 manually by using
grid.Model.Selections.Add(GridRangeInfo.Row(3));
- while the highlight changes, I don't know how to get a mapping between the model data and the row index required by GridRangeInfo.Row().

Hope you can help,

Best regards,

Friedrich

Rajasekar G [Syncfusion]
Replied On December 26, 2012 10:40 AM UTC

Hi Friedrich,

 

Thank you for your interest in Syncfusion products.

 

We have analyzed your query and you can achieve your requirement by using the following code snippet.

 

Code snippet[C#]:

grid.Model.SelectedRanges.Add(GridRangeInfo.Row(rowindex));

grid.Model.Grid.InvalidateCell(GridRangeInfo.Row(rowindex));

We have prepared a sample based on this and it can be download from the following location.

Sample Location: http://www.syncfusion.com/downloads/Support/DirectTrac/102493/GridDataControlSample1122105268.zip

Note:

1.       Run the sample.

2.       Click the button AddSelectedRange button to select the first record from group.

And you can map the recordindex and rowindex by using the following code snippet.

Code Snippet[C#]:

//record index from the rowindex
int recordindex = grid.Model.ResolveIndexToRecordPosition(rowindex);
 
//rowindex from the recordindex
int rowindex = grid.Model.ResolvePositionToIndex(recordindex);

Please let us know if you have any questions.

Regards,

Raja sekar.G


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

;