Select previously selected row after refresh

6 posts, 0 answers
  1. Vikas
    Vikas avatar
    36 posts
    Member since:
    Dec 2015

    Posted 03 Aug Link to this post

    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

     

  2. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 08 Aug Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vikas
    Vikas avatar
    36 posts
    Member since:
    Dec 2015

    Posted 09 Aug in reply to Stefan X1 Link to this post

    Thanks,

    I will try this.

  5. Vikas
    Vikas avatar
    36 posts
    Member since:
    Dec 2015

    Posted 22 Aug in reply to Vikas Link to this post

    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>

  6. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 24 Aug Link to this post

    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.
  7. Vikas
    Vikas avatar
    36 posts
    Member since:
    Dec 2015

    Posted 06 Sep in reply to Stefan X1 Link to this post

    This looks much better, Still testing all the different cases.
Back to Top
UI for WPF is Visual Studio 2017 Ready