Automated positioning within DataList

Hi!

I have a DataList that gets it's elements from a collection, that gets it's data from an web service (JsonpRequest)
I want the DataList to scroll to a certain position inside the list.
Say there are 50 elements in the collection and after collection gets filled, i need the datalist to scroll and focus on element 25.

The way i do it now is
resultList.scrollToIndex(position+5);
//this is to show the required position in the middle of the list
resultList.focusOnIndex(position);

This does not seem to work too reliably though (doesn't seem to work at all). Seems to have something to do with the fact that if i try to scroll to relevant position during callback of the collection go() event

What's the good and correct way to position focus around the desired element in the datalist?

Comments

  • I initially tried positioning the scroller on a callback function for collection.fetch(), but that didn't work. Most likely due to the fact that when callback fires, the datalist hasn't still rendered the list and positioning doesn't know where to scroll to. Now i fire off a delayed event during collection fetch callback (400 ms or so) which positions the scroller.

    Are you saying that handling collection.fetched event will be fired when the datalist has done rendering and will produce a more reliable result?
  • 2.3 pre 10.
    One that comes with LG SDK. And nothing i can do about a different version
Sign In or Register to comment.