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

Select previously selected row after refresh

5 Answers 1155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 03 Aug 2016, 08:40 PM

I have a grid view that is data bound to a collection of objects, The grid gets refreshed every 30 seconds, we are getting he data from rest service and we create new objects for every refresh.

If user selects a row, I want to keep that selection after the refresh, I have my own logic to remember the last item and after the itemsource is updated I set the selectedItem to the previously selecteditem

But the problem is that after the data is loaded there is a selected item change event raised by the grid and it sets the selection to first row, I know this is because i have set IsSynchronizedWithCurrentItem="True", But i need that to show the row indicator, Also if i do not set that to true the row is selected but it does not have any focus, I mean visually you can tell that the row is selected it does not have the border or selected item color.

Is there any way that I can keep IsSynchronizedWithCurrentItem="True" and also set the selected item after the refresh and after the grid has raised its last selected item changed event.

The order of events is like this

- Update collection, - i set previous item - grid set the item to null - then grid set the item to first row

 

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Aug 2016, 08:03 AM
Hello Vikas,

I am attaching a sample application demonstrating how the SelectedItem property of RadGridView can be set. For this purpose, I have used the DataLoaded event of the control. You can take a look at the events Overview article for further reference.

As to your other question concerning the focus and selected row color, I have set the EnableLostFocusSelectedState property to False. Can you please check it out and let me know whether this is the visual appearance you are aiming  for? More information on this matter can be found in the Stop Showing the Unfocused State help topic.

If further assistance is needed, feel free to update me.

All the best,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Vikas
Top achievements
Rank 1
answered on 09 Aug 2016, 06:40 PM

Thanks,

I will try this.

0
Vikas
Top achievements
Rank 1
answered on 22 Aug 2016, 05:40 PM

DataLoaded event is not firing every time for all the grids, I have several grids on a user control and the data is refreshed every 30 sec for all the grids, The event fires only once for most of the grid and does not fire after that. If i attach an event handler then it is called every time.

I am using event trigger

<i:Interaction.Triggers>
                    <i:EventTrigger EventName="DataLoaded">
                        <cmd:EventToCommand Command="{Binding GridDataLoadedCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>

0
Stefan
Telerik team
answered on 24 Aug 2016, 02:05 PM
Hello Vikas,

Can you please try the same approach with the EventToCommandBehavior? On my side the DataLoaded event seems to be firing correctly with it.

Please update me if the event is raised as expected at your end as well.

All the best,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Vikas
Top achievements
Rank 1
answered on 06 Sep 2016, 01:36 PM
This looks much better, Still testing all the different cases.
Tags
GridView
Asked by
Vikas
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Vikas
Top achievements
Rank 1
Share this question
or