help with DataList

Just started using DataList. I've looked at the nightly sampler and the DataList.js code and used it at a starting point.

However, I'm having trouble figuring out how it's dealing with selection/deselection. I see an "ontap" event, but when I modify the code for my use case scenario, the whole List seems to have a selected class attached to it (i.e., the whole list is blue) instead of the individual data elements.

Tapping on each item doesn't change the selection class and i'm not sure if I should be manually setting "enyo-selected" after capturing the ontap event?



  • Well, I had some more fun digging into the CSS and figured out it adds "selected" class to the tapped one. Next step, adding collapsible dividers to items :)
  • But while we're on the subject, is there a way NOT to have the DataList blank while refreshing. That is, after the initial load, I don't want it to flicker white while it is retrieving the data from the server...
  • Yeah -- you want to suppress notifications from the enyo.Collection object while you're updating it. You can do this using collection.stopNotifications(), then making the changes, then calling collection.startNotifications() to start things back up.

    By default, changes made while notifications are stopped are queued up to be delivered when it's restarting, with multiple changes to the same property collapsed into one notification.
  • Okay, sounds good. Where should I be putting the startNotifications()? I tried in the successhandler, as well as didFetch in my collection but both result in a blank/white render until processing is done...
  • ah, you're using a store to retrieve... I'll have to think about that.
  • What I'm doing now is creating a separate 2nd collection, attaching a listener to it for the "add" event, then when received, i'm adding the records received into the first collection. Seems to be working.

    BTW, in the 2nd snippet of code, is the 3rd argument supposed to be the records? What I'm getting is an object with an array labeled "records" but the array looks like [0,1,3,4,5,6,7] (i.e. the indices of # records received). Bug or feature? :)
    		loadingCollection.addListener("add", this._collectionChanged, this);
    	_collectionChanged: function(col, method, recs){
    		console.log("_collectionChanged", col, method, recs);}
  • Feature. You can easily request those indices from the reference to the collection. The reason is because they may/may-not have been instantiated at that point since it attempts to do this lazily.
Sign In or Register to comment.