This is a migrated thread and some comments may be shown as answers.

CurrentPosition always 0

6 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 13 Jul 2012, 01:53 PM
Hi,

I use Telerik 2012.1.326.35 and I have a problem with the CurrentPosition property. Actually in our application we have a RadGridView with 12 items. I double-click on an item (ie: 4) in the grid, we popup a dialog with the RadGridView as reference. In the loaded event of the dialog we popup, the RadGridView.Items.CurrentPosition is always equal to 0. If we do an Indexof(SelectedItem), the call return the exact position of the selected item in the grid. Can you explain why the CurrentPosition position is always equal to 0 ???

Thank's

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 16 Jul 2012, 11:49 AM
Hi,

 Please note that the "CurrentItem" and "SelectedItem" are not necessary one and the same rows. In your case I would advise you to set RadGridView's IsSynchronizedWithCurrentItem property to True. That way you will keep the SelectedItem synchronized with RadGridView's CurrentItem property. Then gridView.Items.CurrentPosition should work as expected. 

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Oliver
Top achievements
Rank 1
answered on 16 Jul 2012, 01:42 PM
Hi Didie,

I fully understand that CurrentItem and SelectedItem are not always the same!!! The IsSynchronizedWithCurrentItem is equal to TRUE and the CurrentPosition are always equal to 0 :(

I had to use the following strategy to solve my issue:

            if (mGridView != null && mGridView.SelectedItem != null)
            {
                currentPosition = mGridView.Items.IndexOf(mGridView.SelectedItem);
            }

Thank's
0
Dimitrina
Telerik team
answered on 16 Jul 2012, 01:58 PM
Hi,

 I have tested the case with the ItemsSource for the GridView being DataView, ObservableCollection or QueryableCollectionView. If your source is ICollectionView, then you could as well work with the current position of the bound source.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Oliver
Top achievements
Rank 1
answered on 16 Jul 2012, 02:00 PM
Hi Didie,

the ItemsSource of my GridView correspond to an array of object.

ie: HomeMadeObject[]

Thank's
0
Dimitrina
Telerik team
answered on 19 Jul 2012, 01:05 PM
Hello,

 I have tested the situation when the ItemsSource for the RadGridView is an Array and I was able to get the CurrentPosition fine. Please find the test project attached for a reference.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dimitrina
Telerik team
answered on 19 Jul 2012, 01:06 PM
Hello,

 It seems that the file was not attached properly. I have added it again.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Oliver
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Oliver
Top achievements
Rank 1
Share this question
or