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

Selection style lost when paging...

8 Answers 464 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 05 Feb 2013, 03:45 PM

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


8 Answers, 1 is accepted

Sort by
0
Lee
Top achievements
Rank 1
answered on 05 Feb 2013, 04:19 PM
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...
0
Iliana Dyankova
Telerik team
answered on 06 Feb 2013, 08:46 PM
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!
0
Lee
Top achievements
Rank 1
answered on 06 Feb 2013, 09:15 PM
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
0
Iliana Dyankova
Telerik team
answered on 08 Feb 2013, 05:47 PM
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!
0
Lee
Top achievements
Rank 1
answered on 08 Feb 2013, 05:57 PM

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.

0
Iliana Dyankova
Telerik team
answered on 12 Feb 2013, 05:11 PM
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!
0
Lee
Top achievements
Rank 1
answered on 12 Feb 2013, 08:49 PM
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?
0
Iliana Dyankova
Telerik team
answered on 15 Feb 2013, 03:24 PM
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!
Tags
ListView
Asked by
Lee
Top achievements
Rank 1
Answers by
Lee
Top achievements
Rank 1
Iliana Dyankova
Telerik team
Share this question
or