Selection style lost when paging...

9 posts, 0 answers
  1. Lee
    Lee avatar
    37 posts
    Member since:
    Oct 2012

    Posted 05 Feb 2013 Link to this post


    Hello,

    I have a ListView defined with a corresponding pager. I have my selection being applied similar to your selection demo and my issue occurs when paging through the list view items, after selecting an item, if navigating to a new page I would expect one of the following two scenarios to occur:

    1) The selection is retained...Selected data and UI style selection upon return to page of items containing selected item
    2) The selection is cleared....Selected data is cleared and UI style selection is removed from previously selected item upon return

    What I am experiencing appears to be that the selected data is retained but the UI selection style is removed from the selected item upon return to page of items containing selected item.

    This undesirable behavior can bee seen on your demo here:  http://demos.kendoui.com/web/listview/selection.html


    Are the UI selection styles being intentionally cleared from the selected item when paging to a different page?


    (I am aiming to toggle the enabled state of my 'Ok' button based on whether an item is currently selected or not...)


    Thanks,
    Lee


  2. Lee
    Lee avatar
    37 posts
    Member since:
    Oct 2012

    Posted 05 Feb 2013 Link to this post

    I am seeing this same behavior with the grid, as well....

    Change event never fires when paging, and when I page back to view the selected item, its selection styles are lost....


    http://demos.kendoui.com/web/grid/selection.html


    1) Select a row in the grid on page 1, note it gets highlighted
    2) Navigate to page 2
    3) Navigate back to page 1 to view your previous selection...selection highlight is no longer present...
  3. Kendo UI is VS 2017 Ready
  4. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2593 posts

    Posted 06 Feb 2013 Link to this post

    Hello Lee,

    The observed behavior is by design - when paging to a different page the Grid / ListView is rebound and the selection is lost. In order to save the selection you can use the change event of the Grid / List View to save the current selection and then in the DataBount event (Grid / ListView) to restore the last selection.

    Regards,
    Iliana Nikolova
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Lee
    Lee avatar
    37 posts
    Member since:
    Oct 2012

    Posted 06 Feb 2013 Link to this post

    Iliana,

    Thank you for your prompt response.  

    If the selection is lost I would expect that the 'change' event would be fired in the same fashion that it is when I call 'clearSelection()'....

    If in fact the selection is being cleared when paging to a different page, why is the 'change' event on the grid not being raised in the same fashion it is when calling clearSelection()?


    Thanks again!

    - Lee
  6. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2593 posts

    Posted 08 Feb 2013 Link to this post

    Hi Lee,

    By design Kendo UI events fire when user interacts with the widgets, i.e. the change event will fire only in case the user click on the row to change the selection (not when you clear selection with code).
     

    Regards,
    Iliana Nikolova
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Lee
    Lee avatar
    37 posts
    Member since:
    Oct 2012

    Posted 08 Feb 2013 Link to this post


    Below is pulled right from the ListView API documentation...Methods section, for 'clearSelection()'....Notice how it states the 'change' event is triggered...

    clearSelection

    Clears ListView selected items and triggers change event.

  8. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2593 posts

    Posted 12 Feb 2013 Link to this post

    Hi Lee, 

    First of all, let me apologize because I misunderstand you. Generally speaking, changing the page will trigger DataSource's change event (i.e. the data is changed). As I mentioned in my first post, the selections is lost because the Grid is rebound, i.e. its rows are re-rendered.

    Regarding the clearSelection() method - yes, it triggers the change event (example).

    Kind regards,
    Iliana Nikolova
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  9. Lee
    Lee avatar
    37 posts
    Member since:
    Oct 2012

    Posted 12 Feb 2013 Link to this post

    Iliana,

    What I have found is that changing the page is not causing the 'change' event to fire... BUT IS clearing the selection (...you told me)
    Calling 'clearSelection()' is causing the 'change' event to fire.


    What I am wondering is that if you are 'clearing the selection' automatically when a new page is fetched, why would the 'change' event not fire in a similar fashion to the way it does when 'clearSelection()' is called?

    The behavior you described in your last post is what I am after... if 'clearSelection()' triggers a 'change' event when being called, then when Kendo is automatically clearing the selection behind the scenes (due to paging), I would expect the same 'change' event to fire.

    Do you see what I am getting at?
  10. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2593 posts

    Posted 15 Feb 2013 Link to this post

    Hello Lee,

    I understand you, but this is the default Grid's behavior - when paging the item bound to the Grid is changed and the Grid is rebound to show the changes. Hence, this rebind will cause the selection to be lost. 

    Regards,
    Iliana Nikolova
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready