Wrong set spot control in DataGridList

Hi all,
I have a moon.DataGridList that have 2 row moon.GridListImageItem
{<br /> kind:"moon.DataGridList",<br /> name:"resultList",<br /> minWidth:250,<br /> minHeight:300,<br /> space:20,<br /> fit:true,<br /> ontap:'itemSelected',<br /> scrollerOptions:{<br /> vertical:'hidden',<br /> horizontal:'hidden'<br /> },<br /> components:[<br /> {<br /> kind:"moon.GridListImageItem",<br /> centered:false,<br /> useSubCaption:false,<br /> imageSizing:"cover",<br /> spotlightType:'img',<br /> style:"width:271px; height:271px",<br /> <br /> }<br /> ]<br /> },
image
and

then i custom spotlithRightChange to catch when at item 6th press right it next to 7th item, but spotlight jum to 8th item.
spotlightRightChanged:function(inSender,inEvent){<br /> console.log(inEvent.index);<br /> if(inEvent.index == 5){<br /> var components = this.getComponents();<br /> console.log(this.$.resultList.childForIndex(6));<br /> enyo.Spotlight.setCurrent(this.$.resultList.childForIndex(6));<br /> }else if(inEvent.index == 11){<br /> if(this.currentPage+1<=this.totalPage) {<br /> this.set("currentPage",this.currentPage+1);<br /> console.log('Next trang');<br /> enyo.Spotlight.spot(this.$.resultList.childForIndex(0));<br /> this.$.resultList.reset();<br /> this.collection.set("offset", 100 * Math.random());<br /> }<br /> }<br /> },

Please help me fix it,

Comments

  • My guess is you need to return true; in your onSpotlightRight handler. Without that, the event will bubble up to the main spotlight handler which will try to focus the control to the right of the currently spotted (which you programmatically set to the 7th) which is the 8th.
  • Many thanks @theryanjduffy, it solved my problem.
  • Hi @theryanjduffy and all, how to catch event moon.DataGridList finished render all item?
    I try to use rendered function to raise event to parent component but not working
    ..<br />components:[<br />{<br /> kind:"moon.DataGridList",<br /> name:"resultList",<br /> minWidth:250,<br /> minHeight:334,<br /> classes:"item-square",<br /> space:20,<br /> fit:true,<br /> style:'margin-top:20px',<br /> ontap:'itemSelected',<br /> scrollOptions:{<br /> vertical:'hidden',<br /> horizontal:'hidden'<br /> },<br /> events:{<br /> onRenderFinished:''<br /> },<br /> rendered:function(){<br /> this.inherited(arguments);<br /> this.doRenderFinished();<br /> },<br /> components:[<br /> {<br /> kind:"moon.GridListImageItem",<br /> centered:false,<br /> useSubCaption:false,<br /> imageSizing:"cover",<br /> spotlightType:'img',<br /> style:"width:271px; height:271px",<br /> scrollOptions:{<br /> vertical:'hidden',<br /> horizontal:'hidden'<br /> },<br /> bindings:[<br /> {from:"model.title", to:"caption"},<br /> {from:"model.tv_thumb_url",to:"source"},<br /> {<br /> from:"model.vip_mode",<br /> to:"vip",<br /> transform:function(data){<br /> this.removeClass('vip');<br /> if(data>0) {<br /> this.addClass('vip');<br /> }<br /> return data;<br /> }<br /> }<br /> ]<br /> }<br /> ]<br /> },<br />]<br />
  • DataList employs a deferred rendering strategy to improve rendering performance. Unfortunately, it doesn't have a public API to hook into completing that rendering.

    You have a couple options: set renderDelay to null and leave your code as is (the public API way) or override didRender instead of rendered (the private API way).
  • Thanks @theryanjduffy, i check DataGridList not have rendered function, when i move code events:{<br /> onRenderFinished:''<br /> },<br /> rendered:function(){<br /> this.inherited(arguments);<br /> this.doRenderFinished();<br /> }, into moon.GridListImageItem i can catch onRenderFinished event in parent, but it show warning log.

    enyo.kind.inherited: unable to find requested super-method from -> undefined in moon.GridListImageItem, how to fix that warning?
  • @theryanjduffy : i have a moon.Panels with CarouselArranger kind and include 2 panels (HomePanel and ListPanel). ListPanel is paginator page, when active panel is ListPanel (ListPanel show, HomePanel hide) and i next page, i see a problem that in loading data of new page, panels lost focus current panel (ListPanel) and HomePanel is showed after loaded data, it show ListPanel again and hide HomPanel. How to fix not show HomePanel when i loading data new page in ListPanel?? Thank you somuch:smile:
    {<br /> name: "panels",<br /> kind: "moon.Panels",<br /> animate:false,<br /> arrangerKind: "CarouselArranger",<br /> classes: "enyo-fit full",<br /> components:[<br /> {<br /> name:'HomePanel',<br /> kind:'clip.HomePanel'<br /> },<br /> {<br /> name:'ListPanel',<br /> kind:'clip.ListPanel'<br /> }<br /> ]<br /> }
  • I'm not sure what the problem is based on your description. Are you able to reproduce it within jsfiddle?
  • edited May 2016
    Hi @theryanjduffy how to set spot in focus event, in my code i check if item2 focus, i set spotlight item1, but not working.
    enyo.kind({<br /> name:'test',<br /> classes:'moon enyo-fit',<br /> components:[<br /> {<br /> name:'item',<br /> kind:'moon.Item',<br /> content:'item 1'<br /> },<br /> {<br /> name:'item2',<br /> kind:'moon.Item',<br /> content:'item 2'<br /> }<br /> ],<br /> handlers:{<br /> onSpotlightFocus:'focus'<br /> },<br /> focus:function(inSender, inEvent){<br /> if(inEvent.originator.name =="item2"){<br /> console.log('focus 2 ');<br /> enyo.Spotlight.spot(this.$.item);<br /> }<br /> }<br />});

    https://jsfiddle.net/tienn2t/n48hk3ae/1/
  • edited May 2016
    There are a couple ways to control spotlight. If you want to prevent a control from being spotted, you can either set spotlightDisabled: false on it which will cause Spotlight to skip it or you can return true; from the onSpotlightFocus handler either on that control on one of its ancestors. If you do the latter, you should also programmatically spot something otherwise spotlight focus will disappear. In the former case, Spotlight correctly handles spotting a different control.

    Similar to your code above, you can also programmatically spot another control in the onSpotlightFocused handler which would effectively move the focus to that control after the first had focus. The nuanced difference here is that in handling onSpotlightFocus and returning true, the control never receives spotlight focus (iow, control != enyo.Spotlight.getCurrent()) whereas when handling onSpotlightFocused, the control receives focus (control == enyo.Spotlight.getCurrent()) and then it is immediately moved to another control.

    Hope that helps!
  • thank you @theryanjduffy so much, i call spot in onSpotlightFocused event and success spotlight to item, many thanks for your support
    spotlightFocused:function(inSender,inEvent){<br /> if(inEvent.originator.for == 'item2') {<br /> enyo.Spotlight.spot(this.$.item);<br /> }<br /> },
Sign In or Register to comment.