The problem is that you are assigning the dataProvider itself
back to the selectedItems of the same array.
I am not sure exactly what is happening, but clearly it is a
One fix would be to copy the dg array:
lst.selectedItems = dp.slice(); //I tried this it works
Be careful using this with an array of objects though. As I
recall, it doesn't copy the object elements, but puts references to
the original objects into the new array. This is not a problem for
an a rray of strings or other primitive objects.